Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Julian date to calendar dates within a data frame

Tags:

date

dataframe

r

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.

like image 640
user3057402 Avatar asked Dec 26 '13 18:12

user3057402


People also ask

How do you convert a Julian date to a regular date in mainframe?

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.

How do you convert from Julian to Gregorian calendar?

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.

How do I convert a Julian date in R?

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.


1 Answers

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.

like image 128
Roland Avatar answered Oct 10 '22 18:10

Roland