I have a data frame
> df
Age year sex
12 80210 F
13 9123 M
I want to convert the year 80210 as 26june1982. How can I do this that the new data frame contains year in day month year formate from Julian days.
You can convert julian date format ( YYDDD) TO YYYYMMDD format using following intrinsic functions. ws-date-int = FUNCTION INTEGER-OF-DAY(argument-1) The INTEGER-OF-DAY function converts a date in the Gregorian calendar from Julian date form (YYYYDDD) to integer date form.
Assuming that the date is in cell A1, here is the Excel formula to convert Gregorian dates to JDE Julian: =(YEAR(A1)-1900)*1000+A1-DATE(YEAR(A1),1,1)+1.
In R, the julian function converts a date-time object into a Julian date: the number of day since day 0 (default is 1970-01-01). However, there is no function, without loading another package, that converts a Julian date back into a date object. The julian2date function does this conversion.
You can convert Julian dates to dates using as.Date
and specifying the appropriate origin:
as.Date(8210, origin=as.Date("1960-01-01"))
#[1] "1982-06-24"
However, 80210 needs an origin pretty long ago.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With