Sample data:
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
)
Producing:
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
I want to match the column t1$CName column to the column headings oft2.
The Desired output is:
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
It seems to me that you really want to merge the transpose of
t1witht2:Step 1: Create a transposed copy of table
t1:Step 2: Merge
Step 3: Now all you have to do is remove the columns you don’t need.
Even for your stated data size of 1000 entries this should not be a problem for R.