title: Aligning multiple zoo objects at once in R
body: <p>Consider the following zoo objects:</p>
  
  <pre><code> x &lt;- data.frame(Date = seq(as.Date("2013-02-01"), length=6, by="1 month") - 1, x = seq(6))
   y &lt;- data.frame(Date = seq(as.Date("2013-02-01"), length=4, by="1 month"), y = seq(4))
   z &lt;- data.frame(Date = seq(as.Date("2012-11-01"), length=9, by="1 month"), z = seq(9))
  
   x.zoo = zoo(x[,-1], order.by = x[,1])
   y.zoo = zoo(y[,-1], order.by = y[,1])
   z.zoo = zoo(z[,-1], order.by = z[,1])
  </code></pre>
  
  <p>Note that the 3 zoo objects are of different lenghts.
  I would like to align all the objects with respect to the date of variable <strong>"x"</strong>: in other words, I want to create a new dataframe that contains a Date column (index of object x), and fill for each variable with the closest available observation.</p>
  
  <p>Here is the result I am looking for:</p>
  
  <pre><code>         Date x  y  z
   1 2013-01-31 1  1  4
   2 2013-02-28 2  2  5
   3 2013-03-31 3  3  6
   4 2013-04-30 4  4 NA
   5 2013-05-31 5 NA NA
   6 2013-06-30 6 NA NA
  </code></pre>
  
  <p>Note that, in reality, I have 10 variables that I want to align with x.
  I am aware of the function <code>na.locf</code> from the <code>zoo</code> package, but I am not sure how to adapt it in the context of multiple zoo objects.</p>
  
  <p>Is there anyway I could do that efficiently?</p>
  
  <p>Thank you!</p>