我想合并这两个表,但找不到更好的方法。通常,如果我使用合并,它必须至少有一列相互匹配......
data<-data.frame(A=c("A1","A2","A3","A4"),B=c("13131,256","12141","256","684"))
A B
1 A1 13131,256
2 A2 12141
3 A3 256
4 A4 684
我想根据下表合并B列:
BNAME<-data.frame(NAME=c("Red","Green","Yellow","Black"),B=c("13131","256","12141","684"))
NAME B
1 Red 13131
2 Green 256
3 Yellow 12141
4 Black 684
所以最终的格式应该是这样的:
A B NAME
1 A1 13131,256 Red,Green
2 A2 12141 Yellow
3 A3 256 Green
4 A4 684 Black
有没有一种快速的方法来完成这项工作?
非常感谢!!
林普