[R] POSIXct troubles
wouter buytaert
wouter.buytaert at yucom.be
Sat Jun 7 16:18:11 CEST 2003
Hello,
I'm working with POSIXct objects, and I found some strange behavior. I'm
trying to extract a 30min time series from a POSIXct vector, and it
seems that R is having problems with daylight saving time:
> test
[1] "2002-03-31 01:15:00 CET" "2002-03-31 01:30:00 CET"
[3] "2002-03-31 01:45:00 CET" "2002-03-31 03:00:00 CEST"
[5] "2002-03-31 03:15:00 CEST" "2002-03-31 03:30:00 CEST"
[7] "2002-03-31 03:45:00 CEST" "2002-03-31 05:00:00 CEST"
[9] "2002-03-31 05:15:00 CEST" "2002-03-31 05:30:00 CEST"
[11] "2002-03-31 05:45:00 CEST" "2002-03-31 05:00:00 CEST"
[13] "2002-03-31 05:15:00 CEST" "2002-03-31 05:30:00 CEST"
[15] "2002-03-31 05:45:00 CEST" "2002-03-31 06:00:00 CEST"
[17] "2002-03-31 06:15:00 CEST" "2002-03-31 06:30:00 CEST"
[19] "2002-03-31 06:45:00 CEST" "2002-03-31 07:00:00 CEST"
#just a time series.
> ft<-(as.integer(test)%%1800)==0
> ft
[1] FALSE TRUE FALSE TRUE FALSE TRUE FALSE TRUE FALSE TRUE FALSE
TRUE
[13] FALSE TRUE FALSE TRUE FALSE TRUE FALSE TRUE
#And now, when extracting the right entries out of "test":
> test[ft]
[1] "2002-03-31 01:30:00 CET" "2002-03-31 03:00:00 CEST"
[3] "2002-03-31 03:30:00 CEST" "2002-03-31 05:00:00 CEST"
[5] "2002-03-31 05:30:00 CEST" "2002-03-31 05:00:00 CEST"
[7] "2002-03-31 05:30:00 CEST" "2002-03-31 06:00:00 CEST"
[9] "2002-03-31 06:30:00 CEST" "2002-03-31 07:00:00 CEST"
Here, [4] and [5] are wrong...
BTW, is there a way to ask R to use another time zone than the one your
computer is in? I'm working on data that do not use daylight saving
time, but my computer does (west european time zone) and that's quite
confusing when importing/exporting.
Thanks,
Wouter Buytaert
More information about the R-help
mailing list