I am working with a dataset that includes 16 questions where the response set is identical (Yes, No, Unknown or Missing). I am processing the data using R and I want to turn
An R base solution using apply
apply
data.frame(apply(df, 2, factor, levels=c(-9, 0, 1), labels = c("Unknown or Missing", "No", "Yes")))
Using sapply
sapply
data.frame(sapply(df, factor, levels=c(-9, 0, 1), labels = c("Unknown or Missing", "No", "Yes")))