title: cbind two data frames with different rownames and numbers of rows
body: <p>Suppose I have two data frames, each with a different number of rows and columns and sharing some row names but not others. I'd like to be able to cbind them together so that the resultant data frame has all of the unique rownames from from the constituent data frames, and simply puts an 'NA' where the row and column combination did not exist in the constituent data. I thought that there must be some kind of join or merge operation that can do this but I haven't been successful in finding one. Thanks in advance!</p>
  
  <p>Edit: Here's what I wrote and it seems to work, but I'm not sure how robust it is:</p>
  
  <pre><code>new.cbind &lt;- function(...)
  {
    input &lt;- eval(substitute(list(...), env = parent.frame()))
  
    names.orig &lt;- NULL
    nrows &lt;- numeric()
    for (i in 1:length(input))
      {
        nrows[i] &lt;- nrow(input[[i]])
        names.orig &lt;- c(names.orig, colnames(input[[i]])) 
      }
  
    idx &lt;- (1:length(input))[order(nrows, decreasing=T)]
    x &lt;- NULL
    for (i in 1:length(input))
      {
        x &lt;- c(x, rownames(input[[idx[i]]]))
      }
  
    r &lt;- data.frame(row.names=unique(x))
    for (i in 1:length(input))
      {
        r &lt;- cbind(r, data.frame(input[[i]][match(rownames(r), rownames(input[[i]])),]))
      }
  
    colnames(r) &lt;- names.orig
  
    return(r)
  }
  </code></pre>