My dataframe looks something like df, and I would like to replace the values in X1 using a conversion table replacement_table. If values in X1 match the values in replacement_table$coordinates, then that value would be replaced with the corresponding value in replacement_table$location
replacement_table <- data.frame (location = c("locationA", "locationB", "locationC"),
coordinates = c("42.8+-70.89", "42.85+-72.21", "31.28+-72.14"))
df <- data.frame(X1 = c("42.8+-70.89", "42.8+-70.89", "31.28+-72.14", "31.28+-72.14", "42.85+-72.21"),
X2 = c("23.2+-81.32", "42.8+-70.89", "31.28+-72.14", "23.2+-81.32", "42.8+-70.89"),
X3 = c("19371", "0", "0", "19278", "28912"))
The output would look something like this:
df <- data.frame(X1 = c("locationA", "locationA", "locationC", "locationC", "locationB"),
X2 = c("23.2+-81.32", "42.8+-70.89", "31.28+-72.14", "23.2+-81.32", "42.8+-70.89"),
X3 = c("19371", "0", "0", "19278", "28912"))