title: How to use do.call and cbind with a list of objects in a loop?
body: <p>I use <code>do.call</code> and <code>cbind</code> to assemble several xts objects into a more general container <code>data</code>. My objective is to implement a loop for adding the objects directly by their name from a vector. </p>
  
  <p>Here is the original <code>do.call</code> :</p>
  
  <pre><code>data &lt;- do.call(cbind, c(eapply(e, Cl),
  
                             list(A),
                             list(B),
                             list(C),
                             list(D)
  ))
  </code></pre>
  
  <p>Lists contain xts objects and <code>data</code> is also an xts object.</p>
  
  <pre><code>&gt; str(A)
  An ‘xts’ object on 2014-01-02/2015-05-25 containing:
    Data: num [1:360, 1] 100 98.9 98.5 98.4 98.7 ...
   - attr(*, "dimnames")=List of 2
    ..$ : NULL
    ..$ : chr "A"
    Indexed by objects of class: [Date] TZ: UTC
    xts Attributes:  
   NULL
  </code></pre>
  
  <p>When I define a vector with the name of the xts objects with :</p>
  
  <pre><code>objects &lt;- c(
  
    "A",
    "B",
    "C",
    "D"
  )
  </code></pre>
  
  <p>And then try to make a loop through them, R logicaly handle the vector as characters and only the last entry is added, here <code>"D"</code>. </p>
  
  <p>If I tell <code>list</code> to handle <code>o</code> as an xts object with <code>as.xts</code>, R returns an error saying there is no applicable method for as.xts on object of class character. My understanding is that <code>as.xts</code> must be used on multi-dimentional like data.frame and it is not appropriate here.</p>
  
  <pre><code>for (o in objects){
  
    data &lt;- do.call(cbind, c(eapply(e, Cl), list(as.xts(o))))
  
  }
  </code></pre>
  
  <p>I don't want to create new xts objects from scratch with <code>xts</code> so how can tell <code>list</code> that <code>o</code> is an object and not a string ? or should I use a completly different approach?</p>