title: join matching columns in a data.frame or data.table
body: <h3>I have the following data.frames:</h3>
  
  <pre><code>a &lt;- data.frame(id = 1:3, v1 = c('a', NA, NA), v2 = c(NA, 'b', 'c'))
  b &lt;- data.frame(id = 1:3, v1 = c(NA, 'B', 'C'), v2 = c("A", NA, NA))
  &gt; a
    id   v1   v2
  1  1    a &lt;NA&gt;
  2  2 &lt;NA&gt;    b
  3  3 &lt;NA&gt;    c
  &gt; b
    id   v1   v2
  1  1 &lt;NA&gt;    A
  2  2    B &lt;NA&gt;
  3  3    C &lt;NA&gt;
  </code></pre>
  
  <p><em><strong>note:</strong> There are no ids for which v1 or v2 are defined in both tables; there is only a single unique non-NA value in each column for each id value</em></p>
  
  <h3>I would like to merge these data frames on matching values of "id':</h3>
  
  <pre><code>ab &lt;- merge(a, b, by = "id")
  </code></pre>
  
  <h3>but I would also like to combine the two columns <code>v1</code> and <code>v2</code>, so that the data.frame <code>ab</code> will look like this:</h3>
  
  <pre><code>ab &lt;- data.frame(id = 1:3, v1 = c("a", "B", "C"), v2 = c("A", "b", "c"))
  
  &gt; ab
    id v1 v2
  1  1  a  A
  2  2  B  b
  3  3  C  c
  </code></pre>
  
  <h3>instead, I get this:</h3>
  
  <pre><code>&gt; merge(a, b, by = "id")
    id v1.x v2.x v1.y v2.y
  1  1    a &lt;NA&gt; &lt;NA&gt;    A
  2  2 &lt;NA&gt;    b    B &lt;NA&gt;
  3  3 &lt;NA&gt;    c    C &lt;NA&gt;
  </code></pre>
  
  <h3>it would be helpful to have examples using both <code>data.frame</code> and <code>data.table</code>, so here are the data.table versions of above:</h3>
  
  <pre><code>A &lt;- data.table(a, key = 'id')
  B &lt;- data.table(b, key = 'id')
  A[B]
  </code></pre>