[R] Date issues
Gabor Grothendieck
ggrothendieck at gmail.com
Sat Sep 18 17:57:25 CEST 2010
On Sat, Sep 18, 2010 at 11:25 AM, Santosh Srinivas
<santosh.srinivas at gmail.com> wrote:
> Strangely this is not working ... what am I doing wrong here?
>
>> tDate <- FnO_Data$Date[1]
>> tDate
> [1] 20090101
>> as.Date(c(tDate),format="%Y%m%d")
> [1] NA
>
Do you have zoo loaded? If you do then a minimal reproducible example
(see last line of every message to r-help) is:
> library(zoo)
> as.Date(20090101, format = "%Y%m%d")
[1] NA
Note that numeric arguments here are treated as the number of days
since the Epoch and not as yyyymmdd. As others have pointed out this
works:
> as.Date(as.character(20090101), format = "%Y%m%d")
[1] "2009-01-01"
--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com
More information about the R-help
mailing list