I need to replace strings with numbers across multiple columns. Below is a sample data set:
x <- c("Low Outlier", "High Outlier", "Novice", "Novice", "Emerging", NA, "Proficient", "Approaching")
y <- c("Novice", "Approaching", "Proficient", "Approaching", "High Outlier", "Proficient",NA, "Emerging")
z <- c("High Outlier", "Proficient", "Approaching", "Emerging", "Low Outlier", "Approaching", "Approaching", "Emerging")
sam <- cbind(x,y,z)
I need to convert the "High/Low Outliers" to 0, The NA's to be left as NA, "Novice" to 1, "Emerging" to 2, "Approaching to 3, and "Proficient" to 4.
I have tried to convert a single variable with
sam$x.r <- recode(sam$x.r,'Low Outlier'=0,'High Outlier'=0,'Novice'=1,'Emerging'=2,'Approaching'=3, 'Proficient'=4)
I received an error message of "Warning message:
In recode.numeric(Dat17_18.1$I.E.ScoreStat, Low Outlier
= 0, High Outlier
= 0, :
NAs introduced by coercion"
I am not sure how to recode all of the variables at once.