[R] unexpected behaviour of an extended time series (using packages spuRs and xts)
Olivier ETERRADOSSI
olivier.eterradossi at mines-ales.fr
Thu Jan 14 16:05:39 CET 2016
Hi list,
I thought I knew how to use extended time series (package xts), but I was
wrong J
While preparing a toy example for something else, using data provided in
R, I run into an unexpected problem and cant figure by myself what is
happening below, can anyone of you tell ? I searched the archives but
didnt locate any answer. Probably its trivial, so please forgive :
Im using :
R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree" / Platform:
x86_64-w64-mingw32/x64 (64-bit)
Packages are updated weekly, sometimes daily.
I take some data from package spuRs :
> library(spuRs)
> data(kew)
I turn the dataframe into time series (by combining each kew[,2:13] one
after each other into a vector, and turning the vector into time series).
One is ts :
>
kew.ts<-ts(data=stock,start=kew$year[1],end=kew$year[length(kew$year)],fre
quency=12)
And the other is xts, it looks fine at first :
> kew.xts<-as.xts(kew.ts)
> periodicity(kew.xts)
Monthly periodicity from janv. 1697 to janv. 1999 # OK
> hist(kew.xts) # OK
> summary(kew.xts)
Index kew.xts
Min. :1697 Min. : 0.00
1st Qu.:1772 1st Qu.: 29.70
Median :1848 Median : 47.00
Mean :1848 Mean : 51.14
3rd Qu.:1924 3rd Qu.: 67.60
Max. :1999 Max. :189.00 # OK
> gdata::is.what(kew.xts)
[1] "is.array" "is.atomic" "is.double"
"is.index.unique"
[5] "is.matrix" "is.numeric" "is.object" "is.regular"
[9] "is.time.unique" "is.unsorted" "is.xts" "is.zoo"
# seems OK
# But now, first try :
> plot(kew.xts)
Error in if (on == "years") { :
valeur manquante là où TRUE / FALSE est requis # french for «
missing value where TRUE/FALSE is required »
# hmmmm, lets try something else :
> plot(kew.xts['1697-01/1979/']) # OK
> plot(kew.xts['1697-01/1980/'])
Error in if (on == "years") { :
valeur manquante là où TRUE / FALSE est requis
> plot(kew.xts['1697-01/1979-12/']) # OK
> plot(kew.xts['1697-01/1980-01/'])
Error in if (on == "years") { :
valeur manquante là où TRUE / FALSE est requis
# but
! :
> plot(kew.xts['1979-01/1980/']) # OK !!!!!
And so are :
> plot (kew.xts['1978/1980/'])
> plot(kew.xts['1977/1982/'])
> plot(kew.xts['1977-01/1982-12']) # and so on
Im puzzled ! I have probably missed a trivial point
Can someone tell ?
Thanks a lot list, regards, Olivier
--------------------------
Olivier ETERRADOSSI
Maître-Assistant, HDR
Ecole des Mines dAlès (C2MA, site de Pau)
Ingénierie de l'aspect visuel et tactile des matériaux
Pôle « Recherche sur les Interactions des Matériaux avec leur
Environnement » (RIME)
Hélioparc, 2 av. P. Angot, F-64053 PAU CEDEX 9
Tel : 05 59 30 90 35 (direct) - 05 59 30 54 25 (std)
Fax : 05 59 30 63 68
<http://www.mines-ales.fr/> http://www.mines-ales.fr
<http://www.mines-telecom.fr/> http://www.mines-telecom.fr
[[alternative HTML version deleted]]
More information about the R-help
mailing list