[R] xts indexed with Date class

Giles giles.heywood at cantab.net
Fri Nov 30 10:32:08 CET 2012


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
>



More information about the R-help mailing list