[R] Converting ts into xts and subsetting

P.B. Lecavalier p.barill at gmail.com
Thu Feb 16 04:25:56 CET 2012


I would like to subset observations in a time series using xts, after 
converting from ts to xts.

X=ts(1:100, frequency=12, start=c(1976))

The output:

Feb 1984   98
Mar 1984   99
Apr 1984  100

What happened to January? The index is always one month off, with 
X2["1976-01"] giving me Feb 1976. Should I set the time using something 
else than ts?

I know there is the window function, but the xts format is convenient 
for my needs.

Thank you.

Philippe Baril Lecavalier

More information about the R-help mailing list