I have the following dataframes:
df <- data.frame(x=c('a', 'b', 'c'), y=c(.1,.2,.3))
xev_values <- data.frame(a=.01, b=.02, c=.03)
How do I recode the character variables in the x column of df with the numeric values in xev_values so that I have a new dataframe?
new_df <- data.frame(xev=c(.01,.02,.03), y=c(.1,.2,.3))
I see how to do this "manually" with recode:
new_df <- data.frame(xev=recode(df$x, 'a'=.01, 'b'=.02, 'c'=.03), y=df$y)