[R] as.POSIXct problem?
ripley@stats.ox.ac.uk
ripley at stats.ox.ac.uk
Fri Jan 3 19:45:02 CET 2003
On Fri, 3 Jan 2003, Frank E Harrell Jr wrote:
> Thanks very much for all the helpful responses. In response to Don MacQueen's note,
>
> On Fri, 3 Jan 2003 07:51:42 -0800
> Don MacQueen <macq at llnl.gov> wrote:
>
> > No problem on a couple of systems here, one Solaris and one Mac OS X.
> > See below.
> >
> > The conversion of a character string to a POSIXct is taking place in
> > two steps--character string to POSIXlt, then POSIXlt to POSIXct.
> > Which step has the problem?
> >
> > Compare your unclass(x) with my unclass(x). If it's different, the
> > problem would appear to be in converting text to POSIXlt.
>
> My unclass(x) has one small difference from yours. The $isdst element is c(-1,0) instead of c(1,0).
-1 means unknown, and 1 means in DST. That's not a surprising difference.
> > My guess would be a bug in the underlying Linux code, since, as Dr.
> > Ripley said, your system thinks it's an invalid time--yet the time is
> > not invalid.
> >
> > Does it fail only on that particular day? If there was a EDT to EST
> > change that day, does it fail on other EDT to EST change days? If
> > there was an EDT to EST change that day, did it occur at the usual
> > 2:00 AM? What about EST to EDT changes?
>
> I get NA for any day in 1969 or earlier. Using a time other than midnight did not help. So it's not a problem with time zone changes on a given day (thanks, Brian and Don for suggesting I look at that).
Ahah, so Dirk's guess was right for your machine! That's a new bug in
some version of glibc, I suppose. Exactly what OS are you running, and
version of glibc (if you can tell)?
> Doing as.POSIXlt works fine, but I want POSIXct variables for storage in data frames.
>
> I am at a loss on how to proceed but thanks to all for the help.
Dirk had a Linux machine in (I believe) the same time zone which
gave the right answer. So does mine if I set it to EST.
Try setting tz="GMT" is as.POSIXct if you don't care about times. It looks
from reading the code that this will work. If you are compiling from
source, about line 220 of src/main/datetime.c reads
#ifdef Win32
tm->tm_year >= 70)
#else
tm->tm_year > 02)
#endif
and your machine seems to need the Win32 branch. You might also need it
in localtime0 a few lines later.
We will probably need a configure test for this particular type of
brokenness.
--
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
More information about the R-help
mailing list