[R] Chron, as.POSIXct problem
Brian Beckage
bbeckage at uvm.edu
Wed Nov 12 16:05:39 CET 2003
Dear R list,
I noticed the following 'problem' when changing the format of dates
created with seq.dates() (from the Chron library) using as.POSIXct()
(R 1.8.0 on OSX 10.2.8):
> datesTest<-seq.dates(from="10/01/1952", length=3, by="days");
> datesTest
[1] 10/01/52 10/02/52 10/03/52
# Now changing the format to show year as 1952.
> datesTest<-format(as.POSIXct(datesTest), "%m/%d/%Y")
> datesTest
[1] "09/30/1952" "10/01/1952" "10/02/1952"
>
The dates were shifted by one day. The work around is simple enough, e.g.,
> datesTest<-format(as.POSIXct(datesTest+1), "%m/%d/%Y")
[1] "10/01/1952" "10/02/1952" "10/03/1952"
but I wonder if this is the intended behavior?
Brian
More information about the R-help
mailing list