On Sun, Apr 18, 2010 at 8:25 AM, simeon duckworth <simeonduckwo...@gmail.com> wrote: > 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
Not for me. It starts in January 2009 for me. Also please show your code in such a way that it can be pasted into a session. Either comment out the output using # or else preface input lines with > so its clear what is input and what is output. And show what versions of the software and R you are using and what platform. > z <- zooreg(1:24,frequency=12,start=c(2009,1)) # monthly data starting 2009 > head(z) 2009(1) 2009(2) 2009(3) 2009(4) 2009(5) 2009(6) 1 2 3 4 5 6 > x <- xts(z,as.yearmon(index(z))) > head(x) x Jan 2009 1 Feb 2009 2 Mar 2009 3 Apr 2009 4 May 2009 5 Jun 2009 6 > R.version.string [1] "R version 2.10.1 (2009-12-14)" > win.version() [1] "Windows Vista (build 6002) Service Pack 2" > packageDescription("zoo")$Version [1] "1.6-3" > packageDescription("xts")$Version [1] "0.7-0" I also tried older versions zoo 1.6-0, xts 0.6-8 and R 2.9.2 and got the same result as I got here. ______________________________________________ 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.