Hi, You could try this: Sys.setenv(TZ="GMT") a<-as.Date(15423:15426) x<-xts(seq_along(a),a) print(index(x)) #[1] "2012-03-24" "2012-03-25" "2012-03-26" "2012-03-27" print(as.numeric(index(x))) #[1] 15423 15424 15425 15426 A.K.
----- Original Message ----- From: Giles <giles.heyw...@cantab.net> To: r-help@r-project.org Cc: Sent: Friday, November 30, 2012 4:32 AM Subject: [R] xts indexed with Date class Hi I see a changed behaviour in xts indexed on class Date in the latest versions, versus 2. It seems to be related to changes to/from daylight savings time, happens those weekends. Is it not intended that class Date be used like this, or is this new behaviour incorrect? Giles Example: > a<-as.Date(15423:15426) > x<-xts(seq_along(a),a) > print(x) [,1] 2012-03-24 1 2012-03-25 2 2012-03-25 3 2012-03-26 4 > print(index(x)) [1] "2012-03-24" "2012-03-25" "2012-03-25" "2012-03-26" > print(as.numeric(index(x))) [1] 15423 15424 15424 15425 #for reference, zoo behaves as expected: > z<-zoo(seq_along(a),a) > print(index(z)) [1] "2012-03-24" "2012-03-25" "2012-03-26" "2012-03-27" > print(as.numeric(index(z))) [1] 15423 15424 15425 15426 Package: xts Type: Package Title: eXtensible Time Series Version: 0.8-8 Date: 2012-10-05 Windows 7 64-bit R version 2.15.2 64-bit all packages up-to-date #--------------previously, R 2.13.2 and xts 0.8-2 , showing expected behaviour ----------------- > a<-as.Date(15423:15426) > x<-xts(seq_along(a),a) > print(x) [,1] 2012-03-24 1 2012-03-25 2 2012-03-26 3 2012-03-27 4 > print(index(x)) [1] "2012-03-24" "2012-03-25" "2012-03-26" "2012-03-27" > print(as.numeric(index(x))) [1] 15423 15424 15425 15426 > z<-zoo(seq_along(a),a) > print(index(z)) [1] "2012-03-24" "2012-03-25" "2012-03-26" "2012-03-27" > print(as.numeric(index(z))) [1] 15423 15424 15425 15426 > ______________________________________________ R-help@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. ______________________________________________ R-help@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.