Greetings,

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))
X2=as.xts(X)
X2["1984"]

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

______________________________________________
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.

Reply via email to