[R] Mistakes in date conversion for future date/time (POSIXct)

Winkler, Matthias matthias.winkler at ibp.fraunhofer.de
Mon Apr 7 09:52:57 CEST 2014


Thank you for your answers. They helped me a lot!

I used R 3.1.0 RC and the mistake didn't show up. 

I also made an additional test, the same as David McPearson did: I tried it again with R 3.0.3 on a pc with 2 OS (Windows 7 and Linux). The error showed up at the windows system but not in Linux. So this seems to be a problem related to Windows.

Kind regards
Matthias

 


-----Ursprüngliche Nachricht-----
Von: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Im Auftrag von David McPearson
Gesendet: Sonntag, 6. April 2014 12:19
An: r-help at r-project.org
Betreff: Re: [R] Mistakes in date conversion for future date/time (POSIXct)

I _do_ see this error - on R 3.0.3 / Win XP however, not on R 2.11.1 / Linux.
(Same hardware, 2 x OS, 2 x R versions)

Maybe it's peculiar to to 'doze...

datetimesequenz <- seq.POSIXt(from=as.POSIXct("1960-01-01 00:00"),
to=as.POSIXct("2100-01-01 00:00"), by="1 hour") levels(as.factor(strftime(datetimesequenz, format="%Y"))) [1] "1960" "1961" "1962" "1963" "1964" "1965" "1966" "1967" "1968" "1969"
"1970" "1971" "1972"
 [14] "1973" "1974" ...
 ...
[183] "2154" "2155" "2157" "2158" "2159" "2160" "2161" "2162" "2167"

sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: i386-w64-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252   
[3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C                      
[5] LC_TIME=English_Australia.1252    

attached base packages:
[1] grDevices datasets  splines   graphics  stats     tcltk     utils    
methods   base     

other attached packages:
[1] svSocket_0.9-55 TinnR_1.0-5     R2HTML_2.2.1    Hmisc_3.12-2   
Formula_1.1-1
[6] survival_2.37-4

loaded via a namespace (and not attached):
[1] cluster_1.14.4  fortunes_1.5-0  grid_3.0.2      lattice_0.20-23
rpart_4.1-3    
[6] svMisc_0.9-69   tools_3.0.2  


Cheers,
D.

On Fri, 4 Apr 2014 14:19:09 -0700 David Winsemius <dwinsemius at comcast.net> wrote

> On Apr 4, 2014, at 9:54 AM, Duncan Murdoch wrote:
> 
> > On 04/04/2014 10:55 AM, Winkler, Matthias wrote:
> >> Dear R-users,
> >> 
> >> I'm working on datasets which contain data from the years 1960 to 
> >> 2100
..
> >> I also produced a date/time-sequence in R, which showed the same 
> >> mistakes (see example below). The mistakes occur at the same dates 
> >> like in my datasets. It's always at the end of march.
> >> > datetimesequenz <- seq.POSIXt(from=as.POSIXct("1960-01-01 
> >> > 00:00"),
> >> > to=as.POSIXct("2100-01-01 00:00"), by="1 hour")
> >> > levels(as.factor(strftime(datetimesequenz, format="%Y"))) >>   [1]
> >> > "1960" "1961" "1962" ...
> >> [181] "2152" "2153" "2154" "2156" "2157" "2158" "2159" "2160" "2161"
> >> "2166" 
> >> Has anybody experienced the same problem and knows a workaround?
> >> 
> >> I'm using R 3.0.1 under Windows 7 64bit. I also tried this with R 
> >> 3.0.3, it showed the same problem. Thank you for your help!
> > 
> > I don't see this in 3.1.0 beta.  Do you?
> 
> I'm not seeing it on a Mac in 3.0.2 either.
> 
> > max(datetimesequenz)
> [1] "2100-01-01 PST"
> > length(datetimesequenz)
> [1] 1227241
> 
> > 
> > Duncan Murdoch
> 
> David Winsemius
> Alameda, CA, USA
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



____________________________________________________________
South Africas premier free email service - www.webmail.co.za 

Fight Crime And Corruption! http://www.anc.org.za/2014/manifesto/

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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