亲爱的,我有一个问题,我有两个这样的数据框:
z=data.frame(x1=c(1,2,5,4,9,1,4,2,9,21),x2=c(2,2,2,4,8,9,1,9,1,1),x3=c("a","b","b","a","a","b","b","b","a","a"))
z1=data.frame(y=c("a","b"),x=c("protein","cell"))
考虑到 z1 的 y 中的级别与 z 的 x3 中的级别相同,我一直在尝试将 z 与 z1 匹配,并且我想要一个新列来显示所有数据框 z 中 z1 的变量 z。我想要一些这样的;我使用了匹配,但我没有得到那个结果。
x1 x2 x3 N
1 1 2 a protein
2 2 2 b cell
3 5 2 b cell
4 4 4 a protein
5 9 8 a protein
6 1 9 b cell
7 4 1 b cell
8 2 9 b cell
9 9 1 a protein
10 21 1 a protein