Hi Gabor

Thats odd. I still get the same problem with the same versions of the
software in your mail ... viz "as.yearmon" converts 2009(1) to "Dec-2008"
and although xts is indexed at "Jan 2009" in xx, using it to create another
xts object with that index reverts to "Dec-2008".

grateful for any suggestions

## code ##
library(xts)
z <- zooreg(1:24,frequency=12,start=c(2009,1))
x <- xts(z,as.yearmon(index(z)))
xx <- x[-1, ]
index(xx)
xxx <- xts(NA[1:length(xx)],index(xx))
periodicity(x)
periodicity(xx)
periodicty(xxx)b

## results ###
> periodicity(x)
Monthly periodicity from Dec 2008 to Nov 2010
> periodicity(xx)
Monthly periodicity from Jan 2009 to Nov 2010
> periodicity(xxx)
Monthly periodicity from Dec 2008 to Oct 2010
>
> R.version.string
[1] "R version 2.10.1 (2009-12-14)"
> win.version()
[1] "Windows XP (build 2600) Service Pack 3"
> packageDescription("xts")$Version
[1] "0.7-0"
> Sys.time()
[1] "2010-04-18 19:37:26 BST"



On Sun, Apr 18, 2010 at 1:25 PM, 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
> 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]]

______________________________________________
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