title: I want to match a column from one table with another table and replace those matching values
body: <p>i have a table say,Table A :</p>
  
  <pre><code>uid pid code
  1     1  aaa
  2     1  ccc
  3     4  ddd 
  4     2  eee
  </code></pre>
  
  <p>i have another table, Table B:</p>
  
  <pre><code>pid msg
  1   good
  2   inspiring
  3   thing to wtch
  4   terrible
  </code></pre>
  
  <p>now, i want to replace pid in table A with msg in Table B.</p>
  
  <p>I used <code>merge(tableA, tableb, by =c("pid"))</code></p>
  
  <p>I got the result as</p>
  
  <pre><code>uid pid code msg
  1    1  aaa  good
  2    1  ccc  good
  3    4  ddd  terrible
  4    2  eee  inspiring
  </code></pre>
  
  <p>where in i want the result as</p>
  
  <pre><code>uid msg code
  1   good aaa
  2   good ccc
  3   terrible ddd
  4   inspiring eee
  </code></pre>