[R] question about seq.dates from chron vs. as.POSIXct

Laura Holt lauraholt_983 at hotmail.com
Wed Jul 7 22:30:47 CEST 2004


Dear R People:

Here is an interesting question:

>library(chron)
>xt <- seq.dates(from="01/01/2004",by="days",length=5)
>xt
[1] 01/01/04 01/02/04 01/03/04 01/04/04 01/05/04
>
#Fine so far
>as.POSIXct(xt)
[1] "2003-12-31 18:00:00 Central Standard Time"
[2] "2004-01-01 18:00:00 Central Standard Time"
[3] "2004-01-02 18:00:00 Central Standard Time"
[4] "2004-01-03 18:00:00 Central Standard Time"
[5] "2004-01-04 18:00:00 Central Standard Time"
>
Why do the dates change, please?  Presumably the as.POSIXct is taking the xt 
as midnight GMT and converting to Central Standard Time.

Is the best solution to:
>as.POSIXlt(xt, "CST")
[1] "2004-01-01 CST" "2004-01-02 CST" "2004-01-03 CST" "2004-01-04 CST"
[5] "2004-01-05 CST"
>

Thanks in advance!

Sincerely,
Laura Holt
who is corrupted by dates and times
mailto: lauraholt_983 at hotmail.com


download! http://toolbar.msn.click-url.com/go/onm00200413ave/direct/01/




More information about the R-help mailing list