R-listers,
I am using xts with a yearmon index, but am getting some inconsistent
results with the date index when i drop observations (for example by using
na.omit).
The issue is illustrated in the example below. If I start with a monthly
zooreg series starting in 2009, yearmon converts this to "Dec-2008". Not
such a worry for my example, but strange. Having converted to xts, i drop
the first observation. The index shows jan 2009. But if i create a new
variable with this index, it shifts the series back to dec 2008.
No doubt i am doing something wrong. very grateful for any tips
library(xts)
z <- zooreg(1:24,frequency=12,start=c(2009,1)) # monthly data starting 2009
x <- xts(z,as.yearmon(index(z))) # starts Dec 2008
xx <- x[-1, ] # drop
first obs (eg through na.omit)
index(xx) # starts
jan 2009
xxx <- xts(NA[1:length(xx)],index(xx)) # back to dec 2008
periodicity(x)
periodicity(xx)
periodicty(xxx)
[[alternative HTML version deleted]]
______________________________________________
[email protected] 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.