绑定时间序列数据与列表不同长度
我有从lapply
输出的时间序列数据,并希望从各自的开始日期开始cbind
一起。在这里,我设置了从随机生成的日期开始的5个随机生成时间序列的示例。
set.seed(123)
d <- lapply(1:5,function(x) ts(rnorm(runif(1,5,20),0,10),start = floor(c(runif(1,2019,2020),runif(1,1,12))),frequency = 12))
我尝试了cbind,cbindna/cbind.na(软件包'qpcr'),data.frame,cbind2等...我找不到适合的工具。使用一个用于填充空空间的循环似乎很愚蠢。 我所需的输出图像:
I have time series data outputted from a lapply
and would like to cbind
them together starting from their respective start date. Here I set an example of 5 random generated time series starting from random generated dates.
set.seed(123)
d <- lapply(1:5,function(x) ts(rnorm(runif(1,5,20),0,10),start = floor(c(runif(1,2019,2020),runif(1,1,12))),frequency = 12))
I tried cbind, cbindna/cbind.na (package 'qpcR'), data.frame, cbind2, etc... I can not find the appropriate tool for this. Using a for loop filling the empty spaces seems silly.
My desired output image:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只需要
cbind()
从base
。使用do.call()
因为d
是列表。输出
输出仍然是
ts
对象。You just need
cbind()
frombase
. Usedo.call()
becaused
is a list.Output
The output is still a
ts
object.