我有两个xts对象:
buypoints
2010-04-20 7.096034
2010-04-22 7.097276
2010-06-02 7.001592
2010-06-10 6.991030
2010-07-09 6.982826
2010-08-27 6.970345
sell points
2010-04-16 7.083497
2010-04-21 7.095015
2010-04-27 7.076409
2010-06-04 6.970617
2010-06-24 6.978857
2010-08-05 7.026258
2010-09-27 7.040676
2010-10-28 7.076468
我想合并这两个对象,以便我的最终输出如下:
2010-04-16 7.083497
2010-04-20 7.096034
2010-04-21 7.095015
2010-04-22 7.097276
2010-04-27 7.076409
2010-06-02 7.001592
2010-06-04 6.970617
2010-06-10 6.991030
2010-06-24 6.978857
2010-07-09 6.982826
2010-08-05 7.026258
2010-08-27 6.970345
2010-09-27 7.040676
2010-10-28 7.076468
也就是说,来自两个对象的数据仅按one column
的时间顺序排列。
请建议一种方法
答案 0 :(得分:0)
您可以尝试以下方式:
rbind(buypoints, sellpoints)
# [,1]
# 2010-04-16 7.083497
# 2010-04-20 7.096034
# 2010-04-21 7.095015
# 2010-04-22 7.097276
# 2010-04-27 7.076409
# 2010-06-02 7.001592
# 2010-06-04 6.970617
# 2010-06-10 6.991030
# 2010-06-24 6.978857
# 2010-07-09 6.982826
# 2010-08-05 7.026258
# 2010-08-27 6.970345
# 2010-09-27 7.040676
# 2010-10-28 7.076468
# > class(rbind(buypoints, sellpoints))
# [1] "xts" "zoo"
看起来xts
已经预见到了按日期排序的需要,从而避免了任何明确的排序函数。非常整洁,嗯?