Recode numeric values in R
numeric, r, recode
Solution
This function does not work on numeric vector. If you want to use it, you can do as follows:
x <- 1:10 # your numeric vector
as.numeric(revalue(as.character(x), c("2" = "33", "4" = "88")))
# [1] 1 33 3 88 5 6 7 8 9 10
Problem
I want to recode some numeric values into different numeric values and have had a go using the following code: `survey$KY27PHYc <- revalue(survey$KY27PHY1, c(5=3, 4=2,3=2,2=1,1=1))` I get the following error: ``` ## Error: unexpected '=' in "survey$KY27PHYc <- revalue(survey$KY27PHY1, c(5=" ``` Where am I going wrong?