title: Merge two data frame and replace the NA value in R
body: <p>I have a main table(a), containing column: id, age, and sex. eg.</p>
  
  <pre><code>a &lt;- data.frame(id=letters[1:4], age=c(18,NA,9,NA), sex=c("M","F","F","M"))
    id age sex
  1  a  18   M
  2  b  NA   F
  3  c   9   F
  4  d  NA   M
  </code></pre>
  
  <p>And I have a supplement table(b), just containing all the missing data in table(a) or duplicated data in table(a). eg.</p>
  
  <pre><code>b &lt;- data.frame(id=c("a","b","d"), age=c(18,32,20))
    id age
  1  a  18
  2  b  32
  3  d  20
  </code></pre>
  
  <p>Now I want to merge the two table, like this:</p>
  
  <pre><code>  id age sex
  1  a  18   M
  2  b  32   F
  3  c   9   F
  4  d  20   M
  </code></pre>
  
  <p>However, I'd tried <code>merge(a,b,by="id",all=T)</code>. The result is not what I want. Is there any way to solve this problem? Thank you!</p>