I have two dataframes dat1 and dat2 and I would like to find matches between the first two columns of the two dataframes and join the values contained in each dataframe for unique pairs.
dat1<-data.frame(V1 = c("home","fire","sofa","kitchen"),
V2 = c("cat","water","TV","knife"), V3 = c('date1','date2','date3','date4'))
V1 V2 V3
1 home cat date1
2 fire water date2
3 sofa TV date3
4 kitchen knife date4
dat2<-data.frame(V1 = c("home","water","sofa","knife"),
V2 = c("cat","fire","TV","kitchen"), V3 = c('col1','col2','col3','col4'))
V1 V2 V3
1 home cat col1
2 water fire col2
3 sofa TV col3
4 knife kitchen col4
The required result would be:
V1 V2 V3 V4
1 home cat date1 col1
2 water fire date2 col2
3 sofa TV date3 col3
4 knife kitchen date4 col4
Any idea on how to do it in R?