I have the following two dataframes:
df = data.frame(From=c("Mike","Elena","Mike","Mark","Alice","Joana"),
To=c("Jasmine","Mariah","Erik","Jack","Joana","Mike"),
Number=1:6, stringsAsFactors = FALSE)
df2 = data.frame(ID=c("1738799","657940","13253","97980","6569874","64839","8494","2773"),
Name=c("Mike","Elena","Mark","Alice","Joana","Mariah","Erik","Jack"),
stringsAsFactors = FALSE)
Dataframe df2 contains the ID associated to most of the names in df. I would like to replace the names in df with the corresponding ID. In this way:
> df
From To Number
1738799 Jasmine 1
657940 64839 2
1738799 8494 3
13253 2773 4
97980 6569874 5
6569874 1738799 6