首页 > 解决方案 > rbind 一个空的 xts 和一个 xts

问题描述

我有一个名为的 xts 对象(单行)Portfolio,如下所示:

               A      B      C       D       E
2010-01-04 61006.1 61628.5 62072.1 60068.66 60088.47

"Portfolio"for 循环的每次迭代都会发生变化,我想创建一个名为 xts 的表Portfolio.Table来保存"Portfolio".

我正在做Portfolio.Table <- xts()并且我正在做的 for 循环中的每次迭代结束: Portfolio.Table <- rbind(Portfolio.Table,Portfolio)但我收到一个错误:data must have same number of columns to bind by row

如何创建具有设定列数的空白 xts 对象?有没有更优雅的方式来做到这一点?

标签: rxtszoo

解决方案


使用rbind.fill

library(plyr)
rbind.fill(data,data2)

推荐阅读