Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我有 2 个这样的时间序列:
y <- ts(rnorm(12), start = c(2000, 1), end = c(2000, 12), freq = 12) z <- ts(rnorm(2), start= c(2001, 1), end = c(2001, 2), freq = 12) ts.union(y, z)
如何附加第二个系列,但只有一列?结果应该再次是 ts(不是 xts)。
您需要ts通过组合两个ts和调整来重新分配您的start,frequency如下所示:
ts
start
frequency
ts(c(y,z), start=start(y), frequency=frequency(y))
输出:
str(df) Time-Series [1:14] from 2000 to 2001: 0.511 -0.0249 -1.353 0.1526 0.9596 ...