title: Merge/overlay data frames to replace only existing values in R
body: <p>How can I merge the two data frames x and y so that existing values in y replace values in x? NAs in y must be ignored.</p>
  <blockquote>
  <p>x &lt;- data.frame(&quot;A&quot;=c(1,&quot;ab&quot;,NA),&quot;B&quot;=c(12,1,5), &quot;C&quot;=c(5,5,10))</p>
  <p>y &lt;- data.frame(&quot;A&quot;=c(NA,NA,NA),&quot;B&quot;=c(60,NA,NA),  &quot;C&quot;=c(NA, 15,NA))</p>
  </blockquote>
  <p>The expected result of the x-y-merge:</p>
  <pre><code>    A   B  C
  1   1  60  5
  2 &quot;ab&quot;  1 15
  3  NA   5 10
  </code></pre>
  <p>x/y can include numeric and non-numeric values and the types should be preserved.</p>