Reputation: 8713
After a call to merge.xts
my resulting time-series object has 3 columns named A.1, B.1, C.1. The original xts objects both have A, B, C columns set. I am assuming the merge was performed on all the common columns as per documentation.
I checked the column contents A, B, C and A.1, B.1, C.1. A call to my.merged[my.merged$A.1 != my.merged$A, ]
returns no rows for all of these columns.
Why the common columns were not collapsed in just one set?
Upvotes: 1
Views: 4410
Reputation: 28913
I think what you may have wanted was rbind
, not merge
. I blogged about this, with example data, at http://darrendev.blogspot.jp/2012/08/small-rxts-code-snippets-and-tips.html (see items 6a and 6b).
If you have the same timestamp in both the xts objects you are merging, then you will get duplicate rows. So to get your desired result you then remove duplicates as a post-process step.
Upvotes: 3
Reputation: 176638
?merge.xts
very clearly says that it is "Used to perform merge operation on 'xts' objects by time (index)." Nowhere does it say that the merge is done on common columns. You probably read that in ?merge
, in reference to the data.frame method.
Upvotes: 4