I have the 2 dataframes below
name<-c("Adam","Bill","Jack")
value<-c(3,2,1)
n<-data.frame(name,value)
name value
1 Adam 3
2 Bill 2
3 Jack 1
id<-c("Adam","Adam","Bill","Jack","Jack")
group<-c("A","A","A","B","B")
e<-data.frame(id,group)
id group
1 Adam A
2 Adam A
3 Bill A
4 Jack B
5 Jack B
in which I want to match the values from n$name and e$id and then create a new column group in n with the respective values found in e$group like:
name value group
1 Adam 3 A
2 Bill 2 A
3 Jack 1 B