I am trying to merge two data of different size by ID. However, for the values that match, both data contain duplicated entries, i.e., there may be three ID #3 in Data A and three ID#3 in Data B. When I try to merge the data, the result is much larger than both data combined.
C<-merge(A,B,by="ID",all.x=T,sort=F)
I want to merge the two data by the ID column, such that the first ID #3 in B pairs with the first ID #3 in A, and so on.
Also, I want the row order of Data A to remain the same. The sort=FALSE wasn't much helpful: It places all the matching rows at the top, and the unmatched rows at the bottom.
Thanks for your help!