[R] date conversion not as i would have expected

Duncan Mackay mackay at northnet.com.au
Wed Oct 21 22:58:27 CEST 2009


This is on WinXP with regional settings as EST (we are now on DST but I run 
EST) R2.9.2

x <- structure(1254351600, class = c("POSIXt", "POSIXct"), tzone = "")
 > x
[1] "2009-10-01 09:00:00 EST"
 > as.POSIXlt(x)
[1] "2009-10-01 09:00:00 EST"
 > as.Date(x, formate="%Y-%m-%d" )
[1] "2009-09-30"

I had a similar problem last week. I am not sure how Bill Gates does his 
times but for R see Rnews 4(1).
There are slight differences between POSIX and Date classes

NB If you run EST in DST periods Bill Gates still gives the file stamp as 
DST in Vista and XP.
I would presume that it is the same for other zones where there is summer 
time zones


Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Email: home: macka at northnet.com.au

At 00:51 22/10/2009, you wrote:
>Good day, i imported some data into R from Excel.  By using the edit()
>function, this is what one of the dates looks like in R:
> > x <- structure(1254351600, class = c("POSIXt", "POSIXct"), tzone = "")
>[1] "2009-10-01 BST"
>However, when i do the following, the date changes:
> > as.Date(x, formate="%Y-%m-%d" )
>[1] "2009-09-30"
>I don't understand why this is happening. I realise that i can get
>around this by doing as.Date(as.character(x)), but would be nice to
>understand why it doesn't work directly.
>C xx
>R-help at r-project.org mailing list
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list