[R] years from as.POSIXlt

Gabor Grothendieck ggrothendieck at myway.com
Wed Mar 10 04:57:43 CET 2004



If you search the mail archives for fromchar there are a number
of discussions of similar bugs that all seem to come from 
German or other European users, suggesting locale problems.

I suspect it won't be easy for others to reproduce this
so you might try to see what you can track down yourself.
fromchar is in as.POSIXlt so perhaps you could
try to get the bug to appear by using as.POSIXlt 
directly and then debugging it using 

    debug(as.POSIXlt)

and as soon as it defines fromchar

    debug(fromchar)

In terms of an interim solution, you could use chron.
For example, for the .leap.seconds problem:

   require(chron)
   .leap.seconds.chron <- chron( format(.leap.seconds,"%m/%d/%Y"), 
                                 format(.leap.seconds,"%H:%M:%S") )
   as.numeric(.leap.seconds.chron) 

where the last line uses the fact that chron stores its dates 
internally as the number of days since January 1, 1970.

---
Date:   Wed, 10 Mar 2004 00:04:30 +0100 
From:   Thomas Petzoldt <thpe at hhbio.wasser.tu-dresden.de>
To:   <r-help at stat.math.ethz.ch> 
Subject:   Re: [R] years from as.POSIXlt 

 
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

> months(.leap.seconds)

works on all systems, a call to

> julian(leap.seconds)

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

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()



Thomas P.




More information about the R-help mailing list