Map a number to a string I have vector c(1,3,4,5,7).
I want convert it in this way: 
c('apple','pie','nuts','cookies','some_other_class') 

Do you have any short ways to do it? Like a switch method or something like that?
Found the solution:

  y &lt;- factor(levels = c(1,3,4,5,7), 
              labels = c('apple','pie','nuts','cookies','some_other_class')
             )