r - 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 对象?有没有更优雅的方式来做到这一点?
解决方案
使用rbind.fill
:
library(plyr)
rbind.fill(data,data2)
推荐阅读
- javascript - 在控制器 NestJS 中的对象内获取 .env 变量
- python - 在训练期间如何在每个 epoch 结束时调用测试集?我正在使用张量流
- bash - 根据另一个文件中的值替换变量
- sql - 将列插入到其中一列不允许空值的新表中
- java - Java FileInputStream.read() 打印时显示不需要的字符
- apache-spark - 如何使用 PySpark 过滤当前日期的 PySpark DataFrame
- python - 我如何获得异步 python 的好处?
- javascript - 完美的循环帧数
- api - 尝试更新视频片段时,我总是收到 Forbidden 响应
- python - Django:计算提交的表单