我有一个结构如下的数据框:
C1 C2 C3 C4 C5
Affected User Affected User Affected User Attachment Affected User
Attachment Attachment Attachment YESIM Attachment
Description.. NA Description.. NA Client ID
Knowledge S.. NA Knowledge S.. NA Description..
NA NA NA NA Knowledge Search
NA NA NA NA Product Impacted
我有另一个数据帧我想用于映射,它的结构是:
x
1 Affected User
2 Application Request Variables
3 Attachment
4 Benetrac Incidents
5 Business Critical Date
6 Client ID
7 Comments
8 Configuration Item
9 Contact Info
10 Description / Priority
11 Knowledge Search
12 Product Impacted
13 QEYE
14 Security Incident Variables
15 SVC - Request for
16 YESIM
现在我想将这些值映射到原始数据框,以便它应该像
C1 C2 C3 C4 C5
1 1 1 3 1
3 3 3 16 3
10 NA 10 NA 6
11 NA 11 NA 10
NA NA NA NA 11
NA NA NA NA 12
谢谢
答案 0 :(得分:1)
你可以做到
do.call(cbind.data.frame, lapply(df1, match, df2$x))
如果你有完全匹配。