[R] POSIXct bug?
Spencer Graves
spencer.graves at pdf.com
Sun Feb 27 05:28:08 CET 2005
In R 2.0.1 under Windows 2000, at least in some cases, as.POSIXct
adds one to the date:
> March1.1959.POSIXct <- as.POSIXct("1959-03-01")
> March1.1959.POSIXlt <- as.POSIXlt("1959-03-01")
>
> (Mar2.59 <- as.Date(March1.1959.POSIXct))
[1] "1959-03-02"
> as.Date(March1.1959.POSIXlt)
[1] "1959-03-01"
>
> as.Date(as.POSIXct(Mar2.59))
[1] "1959-03-02"
> as.Date(as.POSIXct(as.character(Mar2.59)))
[1] "1959-03-03"
> print(POSIX.i <- as.POSIXct("1959-03-01"))
[1] "1959-03-01 Pacific Standard Time"
> for(i in 1:11){
+ print(date.i <- as.Date(POSIX.i))
+ print(POSIX.i <- as.POSIXct(as.character(date.i)))
+ }
[1] "1959-03-02"
[1] "1959-03-02 Pacific Standard Time"
[1] "1959-03-03"
[1] "1959-03-03 Pacific Standard Time"
[1] "1959-03-04"
[1] "1959-03-04 Pacific Standard Time"
[1] "1959-03-05"
[1] "1959-03-05 Pacific Standard Time"
[1] "1959-03-06"
[1] "1959-03-06 Pacific Standard Time"
[1] "1959-03-07"
[1] "1959-03-07 Pacific Standard Time"
[1] "1959-03-08"
[1] "1959-03-08 Pacific Standard Time"
[1] "1959-03-09"
[1] "1959-03-09 Pacific Standard Time"
[1] "1959-03-10"
[1] "1959-03-10 Pacific Standard Time"
[1] "1959-03-11"
[1] "1959-03-11 Pacific Standard Time"
[1] "1959-03-12"
[1] "1959-03-12 Pacific Standard Time"
>
Comments?
Thanks for your help.
spencer graves
More information about the R-help
mailing list