I have two dataframes df1 and df2 which df1 has 3 columns and df2 has 3 columns, I want to match the rows in df1 with the rows as a reference from df2. The df1 is as follows:
df1<-data.frame("id"=c("12e","13e","14e"),"name"=c("sam","susan","alex"),"familyname"=c("son","hen","ken"),"Age"=1:3)
df2<-data.frame("name"=c("sam","susan"),"familyname"=c("son","hen"),"status"=c("married","married"))
I want to only select the rows in df1 that has same name and family name in df2 and also append the status of marriage to the df1. I have tried the following code but I did not get the desire out put.
df3<- df1 %>% filter(df1$name %in% df2$name & df1$familyname %in% df2$familyname)
I want to have the out put like this:
name familyname Age status
sam son 1 married
susan hen 2 married
alex ken 3 divorce