Tiago Marques
2012-Mar-07 00:46 UTC
[R] help with time data - R weird behaviour across machines
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 -- ____________________________________________________________________________________________________ Tiago Andr? Marques Research Unit for Wildlife Population Assessment Centre for Research into Ecological and Environmental Modelling University of St Andrews The Observatory Buchanan Gardens St Andrews Fife KY16 9LZ Scotland Tel: 00441334461842 Fax: 00441334461800 (Scotland office) Tel: 00351210198736 (Portugal home) http://www-maths.mcs.st-andrews.ac.uk/homepages/tam2.html http://www.creem.st-and.ac.uk/tiago/ The University of St Andrews is a charity registered in Scotland : No SC013532
Prof Brian Ripley
2012-Mar-07 01:05 UTC
[R] help with time data - R weird behaviour across machines
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