title: Merging multiple XTS objects by index
body: <p>There are <strong>multiple XTS objects</strong>. Each one contains one column only (of prices).
  The objects may be of different lengths. I want to <strong>merge them by index</strong>.
  I can merge two XTS objects with <code>merge.xts</code>. But I want to merge multiple 
  (with one function, without repeating merging process multiple times).</p>
  
  <p>So I applied the approach recommended <a href="https://stackoverflow.com/questions/12028671/merging-a-large-list-of-xts-objects">here</a>. It works. Just one issue: it merges all data into one column, rather than <strong>placing each XTS object to be merged into its own column</strong>. e.g. In the reproducible example, the desired end result is for XTSM to have 3 columns. </p>
  
  <p>How can that be achieved? Thank you.</p>
  
  <pre><code>library('xts')
  
  #Data
  XTS1 &lt;- structure(c(125.26, 125.14, 125.21, 125.26, 125.21, 125.26, 125.24, 125.22, 125.3, 125.32, 125.38, 125.38, 125.29, 125.26, 125.3, 125.25, 125.29, 125.37, 125.21, 125.3, 125.25, 125.24, 125.21, 125.24, 125.24, 125.26, 125.23, 125.23), class = c("xts", "zoo"), .indexCLASS = c("POSIXct", "POSIXt"), tclass = c("POSIXct", "POSIXt"), .indexTZ = "", tzone = "", .CLASS = "double", index = structure(c(1403537400, 1403538300, 1403539200, 1403540100, 1403541000, 1403541900, 1403542800, 1403543700, 1403544600, 1403545500, 1403546400, 1403547300, 1403548200, 1403549100, 1403550000, 1403550900, 1403551800, 1403552700, 1403553600, 1403554500, 1403555400, 1403556300, 1403557200, 1403560800, 1403561700, 1403562600, 1403563500, 1403564400), tzone = "", tclass = c("POSIXct", "POSIXt")), .Dim = c(28L, 1L))
  XTS2 &lt;- structure(c(1867, 1867, 1868.5, 1868.75, 1868.75, 1868.75, 1868.25, 1867.25, 1867.5, 1867.75, 1868, 1868.25, 1868.25, 1868.75, 1868, 1868.5, 1869, 1869.75, 1868.75, 1868.5, 1868.25, 1867.5, 1867, 1866.75, 1866.75, 1867, 1867.5), class = c("xts", "zoo"), .indexCLASS = c("POSIXct", "POSIXt"), tclass = c("POSIXct", "POSIXt"), .indexTZ = "", tzone = "", .CLASS = "double", index = structure(c(1403537400, 1403538300, 1403539200, 1403540100, 1403541000, 1403541900, 1403542800, 1403543700, 1403544600, 1403545500, 1403546400, 1403547300, 1403548200, 1403549100, 1403550000, 1403550900, 1403551800, 1403552700, 1403553600, 1403555400, 1403556300, 1403557200, 1403560800, 1403561700, 1403562600, 1403563500, 1403564400), tzone = "", tclass = c("POSIXct", "POSIXt")), .Dim = c(27L, 1L))
  XTS3 &lt;- structure(c(1867, 1867, 1868.5, 1868.75, 1868.75, 1868.75, 1868.25, 1867.25, 1867.5, 1867.75, 1868, 1868.25, 1868.25, 1868.75, 1868, 1868.5, 1869, 1869.75, 1868.75, 1868.5, 1868.25, 1867.5, 1867, 1866.75, 1866.75, 1867, 1867.5), class = c("xts", "zoo"), .indexCLASS = c("POSIXct", "POSIXt"), tclass = c("POSIXct", "POSIXt"), .indexTZ = "", tzone = "", .CLASS = "double", index = structure(c(1403537400, 1403538300, 1403539200, 1403540100, 1403541000, 1403541900, 1403542800, 1403543700, 1403544600, 1403545500, 1403546400, 1403547300, 1403548200, 1403549100, 1403550000, 1403550900, 1403551800, 1403552700, 1403553600, 1403555400, 1403556300, 1403557200, 1403560800, 1403561700, 1403562600, 1403563500, 1403564400), tzone = "", tclass = c("POSIXct", "POSIXt")), .Dim = c(27L, 1L))
  
  #Following code merges 2 xts objects into a 2 column xts
  XTSM &lt;- merge(XTS1,XTS2, all=TRUE)
  
  #Following code merges multiple xts objects into a 1 column xts
  XTSlist &lt;- list(XTS1, XTS2, XTS3)
  
  do.call.rbind &lt;- function(lst) {
    while(length(lst) &gt; 1) {
      idxlst &lt;- seq(from=1, to=length(lst), by=2)
      lst &lt;- lapply(idxlst, function(i) {
        if(i==length(lst)) { return(lst[[i]]) }
        return(rbind(lst[[i]], lst[[i+1]]))
      })
    }
    lst[[1]]
  }
  
  XTSM &lt;- do.call.rbind (XTSlist)
  </code></pre>