样本数据:
t1 <- data.frame(
CName=c("334","5as4","ggg","bbb"),
D1=c(1," ",3,1),
D2=c(3,4,5,5)
)
t2 <- data.frame(
PName=c("zz","yy","xx","ww"),
`334`=c(5,6,3,5),
"ggg"=c(7,5,4,3),
`5as4`=c(9,9,1,1),
check.names=FALSE
)
生产:
t1
CName D1 D2
1 334 1 3
2 5as4 4
3 ggg 3 5
4 bbb 1 5
t2
PName 334 ggg 5as4
1 zz 5 7 9
2 yy 6 5 9
3 xx 3 4 1
4 ww 5 3 1
我想将t1$CName
列与t2
.
期望的输出是:
PName 334 ggg 5as4
D1 1 3
D2 3 5 4
1 zz 5 7 9
2 yy 6 5 9
3 xx 3 4 1
4 ww 5 3 1