Skip to content
Prev 155061 / 398506 Next

Building a time series.

On Thu, 4 Sep 2008, rkevinburton at charter.net wrote:

            
You expect wrong. ts.union() is more like cbind() for all combined time 
indexes, ts.intersect() for the intersection of time indexes.
This would never make sense. You have defined both xt0 and xt1 to be time 
series starting at 1(1) and ending at 1(10). Why should xt1 be shifted to 
start at 2(1) and end at 2(10)?
Package "zoo" has a c() command for zoo series. For your example this 
complains

R> c(as.zoo(xt0), as.zoo(xt1))
Error in rbind.zoo(...) : indexes overlap

But if a concatenation makes sense, this works

R> xt1 <- ts(x1, start = 2, frequency=10)

R> c(as.zoo(xt0), as.zoo(xt1))
  1(1)  1(2)  1(3)  1(4)  1(5)  1(6)  1(7)  1(8)  1(9) 1(10)  2(1)  2(2)  2(3)
     0     0     0     0     0     0     0     0     0     0     1     1     1
  2(4)  2(5)  2(6)  2(7)  2(8)  2(9) 2(10)
     1     1     1     1     1     1     1

R> as.ts(c(as.zoo(xt0), as.zoo(xt1)))
Time Series:
Start = c(1, 1)
End = c(2, 10)
Frequency = 10
  [1] 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1

hth,
Z