Basically I am having two data frames and I want to re-code the first data frame with values from the second. The first data frame (df1) is having the data from the respondents to a survey and the other data frame(df2) is the data dictionary for df1.
df1 <- data.frame(a = c(1,2,3),
b = c(4,5,6),
c = c(7,8,9))
df2 <- data.frame(columnIndicator = c("a","a","a","b","b","b","c","c","c" ),
df1_value = c(1,2,3,4,5,6,7,8,9),
new_value = c("a1","a2","a3","b1","b2","b3","c1","c2","c3"))
I know that I can manually re-code the data frame 1 to get the expected output by performing the following:
But my real data-set is having 42 columns that need to be re-coded and that method is a little time taking. All I wanted to know that is there another way in R for me to re-code the values in df1 with the values in df2?