title: how to replace elements of a vector with elements from a vector which match throughout another item in R?
body: <p>how to replace elements of a vector with elements from a vector which match throughout another item in R?</p>
  
  <p>I have:</p>
  
  <pre><code>a &lt;- c(1,2,3,4,5,6)
  b &lt;- c('x','w','e','c','t','z')
  
  c &lt;- c(2,3,5)
  d &lt;- c('xx','vf','z')
  
  df1 &lt;- data.frame(a,b)
  df2 &lt;- data.frame(c,d)
  </code></pre>
  
  <p>I want df2 look like that:</p>
  
  <pre><code>a b
  1 x
  2 xx
  3 vf
  4 c
  5 z
  6 z
  </code></pre>
  
  <p>I have tried so far to merge/join them by "a" so i got:</p>
  
  <pre><code>a b b
  1 x NA
  2 w xx
  3 e vf
  4 c NA
  5 t z
  6 z NA
  </code></pre>
  
  <p>Thank you for your help</p>