title: Merge by column name R
body: <p>I've got</p>
  
  <pre><code>a &lt;- matrix(c(1,3,4,2,2,6,3,1,6), nrow = 3, ncol=3, byrow=TRUE, dimnames = list(NULL, c("Apples", "Pears", "Oranges")))
  
    Pears Apples Oranges
  1     1      3       4
  2     2      2       6
  3     3      1       6
  
  b &lt;- matrix(c(1,3,2,6,3,6), nrow = 3, ncol=2, byrow=TRUE, dimnames = list(NULL, c( "Pears", "Oranges")))
  
    Pears Oranges
  1     1       4
  2     2       6
  3     3       6
  </code></pre>
  
  <p>I want to merge them to get a result as such:</p>
  
  <pre><code> Pears Apples Oranges
  1     1      3       4
  2     2      2       6
  3     3      1       6
  4     1     Na       4
  5     2     Na       6
  6     3     Na       6
  </code></pre>
  
  <p>Ie, <strong>combine them by column name an leave Na/s where the second frame lacks values, for a general case of bigger matrix a, smaller matrix b</strong></p>
  
  <p>rbind does not work, merge does something weird. What am I after? I could do with the most memory efficient thing available too, as this is eventually going to be done a large number of times, with a lot of column names.</p>
  
  <p>Thanks,</p>
  
  <p>-N</p>
  
  <p>EDIT: I probably should have mentioned this when I asked originally, but I actually want to achieve the exact effect as above, but with some pretty major caveats:</p>
  
  <p>I'm using matrices</p>
  
  <p>The first matrix will always contain all and more colnames than the second</p>
  
  <p>I possibly want to create a big.matrix from package bigmemory.</p>