I have two dataframes, one with measurements on individuals:
> head(df1)
ID y1 y2
1 0493B 191.3578 17.26139
2 7393B 241.2554 30.98948
3 Ames-27398 190.8905 52.95530
4 Ames-27399 148.9887 51.09268
5 Ames-27404 162.1147 43.67760
6 Ames-27414 171.2277 42.51208
and a second which is a correspondence key between "ID" and "ID2"
> head(df2)
ID2 ID
1 142462 Vilmorin-I04428
2 142464 Ames-7701
3 142466 Ames-7702
4 142468 Ames-7705
5 142470 Ames-7706
6 142472 Ames-7711
I want to rename the values of "ID" in df1 with their corresponding "ID2" values in df2 in the most straightforward way. My current solution:
order <- match(df1$ID, df2$ID)
key.ordered <- key[order, ]
df1$ID <- df2$ID2
seems extremely cumbersome.