[R] time zone problems

From: Marc Fischer <mlfischer_at_lbl.gov>
Date: Wed 04 Apr 2007 - 05:06:12 GMT


Folks,

I'm having trouble with how datetime objects with time zones are set and plotted. This may be the result of my running R (2.4.0) on a Windoze XP box. Perhaps not. Here are two example problems I need advise on if you have time:

  1. I collect data with dates (often as a fractional day of year) in UTC. Using strptime to create date time objects appears to force the data into the local time zone (including daylight time) of my machine. Setting the tz="UTC" or "GMT" inside strptime seems to be ignored. I made the following cumbersome work around:

foo$date=strptime((paste(yr,DOY), 0, 0), format="%Y %j %H %M",tz="") + 0 tzone.err=as.numeric(as.POSIXct(format(Sys.time(),tz="GMT"))-as.POSIXct(format(Sys.time(),tz="")))*3600 foo$date=foo$date-tzone.err
attributes(foo$date)$tzone="GMT"

Am I missing something obvious or is this a problem with Windoze?

2) Once I have the data in GMT, I try to plot it using the standard plot command but it converts the data back to local time before making the plot. Now the work around is:

plot(foo$date+tzone.err,foo$var, xlab="Date(GMT)")

  Very frustrating... I've read the help pages but can't find answers to these issues. Any help?

Best regards,

Marc



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed Apr 04 15:19:50 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 04 Apr 2007 - 09:31:03 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.