I have a data frame with two columns. The second column contains only integers. More precisely it contains 0,1,2,3 and some NA\'s. Something like this:
id1
You can map values using the mapvalues function from the plyr package. Using the example data from Mike Wise's answer:
library(plyr)
df$val2 <- mapvalues(df$val,
from = c(0,1,2,3,NA),
to = c("ZZT", "ZZU", "ZZV", "ZZW", NA))
If you already have the dplyr package loaded (the successor to plyr), call this function usingplyr::mapvalues() as loading plyr on top of dplyr is problematic.