Hi all,
I am having a problem when converting irregular time series to regular time series. Below a simplified example can be found:
require(zoo)
t <- as.character(c(1981,1984,1985))
d <- c(1,3,6)
dt <- data.frame(d,t)
t <- as.Date(t,"%Y")
z <- zoo(d,t)
plot(z)
ts.d <- as.ts(as.zooreg(z,freq=1)) # create a regular ts object
ts.d # regular time series
I would like to create a regular time series ts.d that looks like this c(1981,NA,NA,1984,1985).
The amazing thing is that the first time that I run this: it works! but when I want to run it again or repeat it (the as.ts()line) it stops workings and I obtain a very long time series:
ts.d # regular time series
Time Series:
Start = 4299
End = 5760
Frequency = 1
[1] 1 NA NA NA NA NA NA NA NA NA NA NA NA NA
[15] NA NA NA NA NA NA NA NA
etc.
What is going wrong?
Cheers, Jan