[R] years from as.POSIXlt

Christophe Declercq cdeclercq at nordnet.fr
Wed Mar 10 10:37:13 CET 2004


As I understand it, there is perhaps something bad with "1970-01-01 00:00",
not in R, but in (at least some versions of) MS-Windows (e.g.
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/26357.html).


> version
         _
platform i386-pc-mingw32
arch     i386
os       mingw32
system   i386, mingw32
status
major    1
minor    8.1
year     2003
month    11
day      21
language R

> Sys.info()[c(1:3,5)]
                      sysname                       release
                    "Windows"                      "NT 5.1"
                      version                       machine
"(build 2600) Service Pack 1"                         "x86"

> Sys.getlocale("LC_TIME")
[1] "French_France.1252"

> as.POSIXct("1970-01-01 01:00:00")
[1] "1970-01-01 01:00:00 Paris, Madrid"
> as.POSIXct("1970-01-01 00:00:00")
Error in fromchar(x) : character string is not in a standard unambiguous
format
> julian(.leap.seconds)
Error in fromchar(x) : character string is not in a standard unambiguous
format

but, of course, 'julian' is OK with another origin

> julian(.leap.seconds, origin=ISOdate(1900,1,1))
Time differences of 26478.5, 26662.5, 27027.5, 27392 [truncated]

Christophe
--
Christophe Declercq, MD
Observatoire regional de la sante Nord-Pas-de-Calais
13, rue Faidherbe
F-59046 LILLE Cedex
Phone 33 3 20 15 49 24
Fax 33 3 20 55 92 30
E-mail c.declercq at orsnpdc.org




> -----Message d'origine-----
> De : r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch]De la part de Prof Brian Ripley
> Envoye : mercredi 10 mars 2004 08:22
> A : Thomas Petzoldt
> Cc : r-help at stat.math.ethz.ch
> Objet : Re: [R] years from as.POSIXlt
>
>
> On Wed, 10 Mar 2004, Thomas Petzoldt wrote:
>
> (without copying me)
>
> > Prof Brian Ripley wrote:
> >
> > > See ?julian, which says
> > >
> > > Note:
> > >
> > >      Other components such as the day of the month or the
> year are very
> > >      easy to computes: just use 'as.POSIXlt' and extract the relevant
> > >      component.
> > >
> >
> > Hello,
> >
> > unfortunately not all mentioned functions work on all machines. Where
>
> No function is mentioned in that note!
>
> >  > months(.leap.seconds)
> >
> > works on all systems, a call to
> >
> >  > julian(leap.seconds)
>
> What is `leap.seconds'?
>
> > julian(.leap.seconds)
>
> works on Windows XP, of course.
>
> > workes perfectly only on Linux (R 1.8.0) but failed on two different XP
> > Machines (German XP version):
> >
> > Error in fromchar(x) : character string is not in a standard
> unambiguous
> > format
>
> What is `leap.seconds' on your machine?  It is an object that as.POSIXct
> is failing on, I suspect (try traceback() to be sure).
>
> > I've tested several things, several versions of msvcrt.dll, different
> > PATH settings, locale set to German or USA, R 1.8.1 and R
> 1.7.1, but the
> >   problem remains.
> >
> > On the other hand
> >
> >  >as.numeric(format(x, f="%d"))
> >
> > works perfectly, so I do not understand what is wrong with julian()
>
> Do *read* the advice on how to get yday quoted above.
>
> --
> 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
>
> ______________________________________________
> 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
>
>




More information about the R-help mailing list