[R] help with time data - R weird behaviour across machines

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Mar 7 02:05:56 CET 2012


What timezones are you and your colleague in?

"2011-03-27 01:00:01" does not exist in some timezones, e.g. 
Europe/London.   As ?as.POSIXlt explains, you can expect such 
non-existent inputs to give NA.

And from ?Sys.timezone:

      Note that except on Windows, the operation of time zones is an OS
      service, and even on Windows a third-party database is used and
      can be updated (see the section on ‘Time zone names’).  Incorrect
      results will never be an R issue, so please ensure that you have
      the courtesy not to blame R for them.

'R weird' was discourteous.


On 07/03/2012 00:46, Tiago Marques wrote:
> Hello list,
>
> I was hoping I could get some help on something which is really giving
> me a headache. I am using R version 2.14.1 (2011-12-22)
> (Platform: x86_64-pc-mingw32/x64 (64-bit))
>
> An object which is supposed to have times has a few elements listed as
> not times but NA's
>
>  > ls()
> [1] "todelete"
>  > class(todelete)
> [1] "POSIXlt" "POSIXt"
>  > todelete
> [1] "2011-03-27 00:59:57" "2011-03-27 00:59:58" "2011-03-27 01:00:01"
> "2011-03-27 01:00:02"
>  > is.na(todelete)
> [1] FALSE FALSE TRUE TRUE
>  > as.numeric(todelete)
> [1] 1301187597 1301187598 NA NA
>
> but on another machine, from a colleague, over the same workspace,
> returns this, as expected:
>
>  > ls()
> [1] "todelete"
>  > class(todelete)
> [1] "POSIXlt" "POSIXt"
>  > todelete
> [1] "2011-03-27 00:59:57" "2011-03-27 00:59:58" "2011-03-27 01:00:01"
> [4] "2011-03-27 01:00:02"
>  > is.na(todelete)
> [1] FALSE FALSE FALSE FALSE
>  > as.numeric(todelete)
> [1] 1301180397 1301180398 1301180401 1301180402
>
> any suggestions about what might be going on here would be greatly
> appreciated.
>
> all the best
>
> Tiago
>


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