I have two data frames. I have a list of column names in a data frame NAME. I then have another data frame DF where the column name is corresponded to data frame NAME in the next column. I need to replace these names to the column names in DF.
DF:
A B C D E
H001 947 95 10 10 678
H002 647 40 10 10 806
H003 840 20 99 53 21
H004 105 10 97 12 44
H005 595 59 76 76 67
NAME:
Name Real.name
A Pete
B May
C Jon
D Paul
E Emma
F Fuchs
G George
Desired output:
Pete May Jon Paul Emma
H001 947 95 10 10 678
H002 647 40 10 10 806
H003 840 20 99 53 21
H004 105 10 97 12 44
H005 595 59 76 76 67
sapply(colnames(DF),function(x) grepl(x,Name$Real.name))?match?paste