Re: [R] Using split() several times in a row?

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Sat 31 Mar 2007 - 21:43:58 GMT

On 3/31/07, Martin Maechler <maechler@stat.math.ethz.ch> wrote:
> >>>>> "SteT" == Stephen Tucker <brown_emu@yahoo.com>
> >>>>> on Fri, 30 Mar 2007 18:41:39 -0700 (PDT) writes:
>
> [..]
>
> SteT> For dates, I usually store them as "POSIXct" classes
> SteT> in data frames, but according to Gabor Grothendieck
> SteT> and Thomas Petzoldt's R Help Desk article
> SteT> <http://cran.r-project.org/doc/Rnews/Rnews_2004-1.pdf>,
> SteT> I should probably be using "chron" date and times...
>
> I don't think you should (and I doubt Gabor and Thomas would
> recommend this in every case):
>
> POSIXct (and 'POSIXlt', 'POSIXt' & 'Date') are part of standard R,
> and whereas they may seem not as convenient in all cases as "chron"
> etc, I'd rather recommed to stick to them in such a case.

There is one change that has occurred since the article that in my mind would let you safely use POSIX but its pretty drastic. At the time of the article you could not set the time zone to GMT in the R process on Windows but now you can do this:

Sys.putenv(TZ = "GMT")

and you can also change it back like this:

Sys.putenv(TZ = "")

Since the problem is that you never can be sure which time zone the time is interpreted in within various function (although you can be pretty sure its either the local time zone or GMT) by setting the process to GMT you make the two alternatives the same so it no longer matters.

Short of the above, the recommendations of the article should be followed. Its not a matter of convenience. Its a matter of being error prone and introducing
subtle time-zone related errors into your code which are very hard to track down or worse, even realize that you have.

Those who claim that its not a problem simply have not used dates and times enough or they would not say that. I have seen posters make such comments on this list only later to run into subtle time zone problems that they never would have had had they followed the advice in the article.

I've used R and dates a lot and therefore have made a lot of programming errors and these recommendations come from bitter experience looking back to see how I could have avoided them.



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 Sun Apr 01 07:47:17 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 Sun 01 Apr 2007 - 05:30:34 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.