如何创建和合并多个XTS对象
我想在循环中合并许多XTS对象。为了这样做,我必须编写以下代码138次。 temp = merge(temp,temp1)temp = merge(temp,temp2)temp = merge(temp,temp3)temp = merge(temp,temp4)
> 有没有办法自动执行该过程?
I want to merge MANY xts objects in a loop. In order to do so, i have to write the following code 138 times.temp=merge(temp,temp1) temp=merge(temp,temp2) temp=merge(temp,temp3) temp=merge(temp,temp4)
is there a way to automate that procedure?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建一个包含对象的列表,然后使用do.call/merge。在下面,如果XTS对象本身具有列名,则可以省略列表的组件名称。尽管在此示例中,日期是相同的,如果不相同,它仍然可以正常工作。
给予:
如果XTS对象具有其名称的模式,例如它们是唯一以x开头的对象,那么此替代方案也可以创建L:
或者如果它们是唯一的XTS对象,那么这将有效地创建列表。
Create a list which contains the objects and then use do.call/merge. Below we could hae omitted the component names of the list if the xts objects themselves had column names. Although in this example the dates are the same it will still work if they are not.
giving:
If the xts objects have a pattern to their names, e.g. they are the only objects whose names start with x then this alternative would also work to create L:
or if they are the only xts objects then this would work to create the list.