On Sat, Sep 18, 2010 at 11:25 AM, Santosh Srinivas <santosh.srini...@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 ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.