i have a table say,Table A :
uid pid code
1     1  aaa
2     1  ccc
3     4  ddd 
4     2  eee
i have another table, Table B:
pid msg
1   good
2   inspiring
3   thing to wtch
4   terrible
now, i want to replace pid in table A with msg in Table B.
I used merge(tableA, tableb, by =c("pid"))
I got the result as
uid pid code msg
1    1  aaa  good
2    1  ccc  good
3    4  ddd  terrible
4    2  eee  inspiring
where in i want the result as
uid msg code
1   good aaa
2   good ccc
3   terrible ddd
4   inspiring eee
 
     
     
    