[R] Numeric to Date
Marc Schwartz
marc_schwartz at me.com
Wed Mar 10 23:04:48 CET 2010
On Mar 10, 2010, at 3:29 PM, GULATI, BRIJESH (Global Markets FF&O NY) wrote:
> Is there easy way to convert numeric to date?
>
> For example:
>
> If I have,
>
> a = as.Date("2010-03-04")
>
> And, if run
>
>> as.numeric(a)
> [1] 14672
>
> Is there any function that I can use to convert 14672 back to the date.
>
> Thx in advance,
> Brijesh
> as.Date(14672, origin = "1970-01-01")
[1] "2010-03-04"
Of course, you would have to know that R stores dates internally as the number of days since 1970-01-01, which is curiously not defined in the help page for ?as.Date, but is on ?Date, which is in the See Also of the former.
HTH,
Marc Schwartz
More information about the R-help
mailing list