mercredi 6 septembre 2017

How to merge two data sets based on the result of matching two columns in R [duplicate]

This question already has an answer here:

I have two data sets df1,df2

> df1
 x1    y1 
  1    5
  1    2   
  1    3     
  1   10

> df2
     x2    y2 
      4    8
      4    7   
      4    9    
      4    3

I want to match y1 in df1 with y2 in df2 ,if there are shared values between them ,I will merge the two data sets
in my EX ,y1 contains 3 and y2 contains 3, so the result will be :

> df3

 x1    y1 
  1    5
  1    2   
  1    3     
  1   10
  4    8
  4    7   
  4    9    
  4    3

Aucun commentaire:

Enregistrer un commentaire