I noticed the addition of the Dates class for dates without times, in R 1.9. I am making extensive use of POSIXct at present and would like to know whether it is worth changing to Dates. What are a few of the trade-offs? Thanks, Frank --- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University
On Thu, 22 Apr 2004, Frank E Harrell Jr wrote:> I noticed the addition of the Dates class for dates without times, in R > 1.9. I am making extensive use of POSIXct at present and would like to > know whether it is worth changing to Dates. What are a few of the > trade-offs?You lose the ability to handle times and timezones. Those who do not understand timezones have no opportunity to make errors. There is probably a little less support for Dates at present, but you can coerce to POSIXct if you need to. (It's really the second point that motivated us.) -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Frank E Harrell Jr <feh3k <at> spamcop.net> writes:> I noticed the addition of the Dates class for dates without times, in R > 1.9. I am making extensive use of POSIXct at present and would like to > know whether it is worth changing to Dates. What are a few of the > trade-offs?Before Date became available I moved all my POSIXct code to chron. It would probably be easier to move to Date than chron since Date seems very close in terms of its interface to POSIXct so you would likely have an easier time of it than I did. The trouble I was having using POSIXct was that its easy to introduce subtle problems into your code without proper attention to time zones. If you look through the archives of r-help you will find numerous examples of the sort of subtle problem that you can inadvertently introduce. The day of the week, day of the month, month of the year, etc. are all time zone dependent since the same date time might represent Monday in one time zone but Tuesday in another. You MUST take great care that you know which timezone each routine that your wrote or are making use of is assuming. Time zones are not part of the problem yet you have to track them. That conflicts with good design since good design means your programs don't depend on extraneous elements. With chron and Date there are no time zones so this type of problem will not occur in the first place.
I can agree with the other responses, and mention that I'm on the other side of the coin, so to speak. The *only* reason I tried R to begin with was to find out if it could handle data whose time scale was in minutes and seconds better than the other software I was using. With its POSIXt class, which had only recently been introduced, it was better. In particular, I needed software that would successfully plot the data as it crossed the boundary between daylight savings time and standard time *and* label the time axis with daylight savings time or standard time as appropriate. R did; the other software did not. -Don At 8:20 AM -0400 4/22/04, Frank E Harrell Jr wrote:>I noticed the addition of the Dates class for dates without times, in R >1.9. I am making extensive use of POSIXct at present and would like to >know whether it is worth changing to Dates. What are a few of the >trade-offs? > >Thanks, > >Frank >--- >Frank E Harrell Jr Professor and Chair School of Medicine > Department of Biostatistics Vanderbilt University > >______________________________________________ >R-help at 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-- -------------------------------------- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA