I am trying to use a function from the forecast package,
seasonaldummy(), which requires a time series object as input, but I have an xts object, call it
x. So first, is it correct that xts objects can not be directly passed to functions that require a
I then tried to coerce it to a
ts object. I tried this by
as.ts(x). The function still produces an error.
I looked at the xts vignette, and in particular the
reclass function, but all I could understand from that was how to coerce non xts objects to xts. It appears I have to do the opposite, and that
as.ts(x) does not work.
I have put a MWE below, where the last two lines generate an error.
> a = rnorm(20) > dt = seq(as.POSIXct("2010-03-24"),by="days",len=20) > library(xts) > a = xts(a,dt) > library(forecast) > seasonaldummy(a) Error in seasonaldummy(a) : Not a time series > seasonaldummy(as.ts(a)) Error in seasonaldummy(as.ts(a)) : subscript out of bounds