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

From: Laura Holt <lauraholt_983_at_hotmail.com>
Date: Thu 08 Jul 2004 - 06:30:47 EST


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@hotmail.com

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



R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jul 08 06:34:59 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 02:34:54 EST