How to merge xts objects with slightly different columns?
<p>Given various one-row xts objects:</p>

<pre><code>z1 = xts(t(c("9902"=0,"9903"=0,"9904"=0,"9905"=2,"9906"=2)),as.Date("2015-01-01"))
z2 = xts(t(c("9902"=3,"9903"=4,"9905"=6,"9906"=5,"9908"=8)),as.Date("2015-01-02"))
z3 = xts(t(c("9901"=1,"9903"=3,"9905"=5,"9906"=6,"9907"=7,"9909"=9)),as.Date("2015-01-03"))
</code></pre>

<p>I want to merge them into a single xts object. But <code>cbind(z1,z2,z3)</code> gives:</p>

<pre><code>           X9902 X9903 X9904 X9905 X9906 X9902.1 X9903.1 X9905.1 X9906.1 X9908 X9901 X9903.2 X9905.2 X9906.2 X9907 X9909
2015-01-01     0     0     0     2     2      NA      NA      NA      NA    NA    NA      NA      NA      NA    NA    NA
2015-01-02    NA    NA    NA    NA    NA       3       4       6       5     8    NA      NA      NA      NA    NA    NA
2015-01-03    NA    NA    NA    NA    NA      NA      NA      NA      NA    NA     1       3       5       6     7     9
</code></pre>

<p>Whereas what I expect is:</p>

<pre><code>           9901 9902 9903 9904 9905 9906 9907 9908 9909
2015-01-01    0    0    0    0    2    2    0    0    0
2015-01-02    0    3    4    0    6    5    0    8    0
2015-01-03    1    0    3    0    5    6    7    0    9
</code></pre>

<p>(I can get the NAs changed to zeroes with giving <code>fill=0</code>, i.e. <code>cbind(z1,z2,z3,fill=0)</code>.)</p>

<p><code>rbind(z1,z2,z3)</code> complains that the rows have different number of columns. But, I believe if if the missing columns were added to each xts object in advance that this would be a good approach?</p>

<p>The real data may have 1000s of rows, and a few hundred columns (once merged), so I've got one eye on efficiency.</p>