Each time when I have to recode some set of variables, I have SPSS recode function in mind. I must admit that it\'s quite straightforward. There\'s a similar recode
recode
If you complete the factor levels you're good to go:
df <- data.frame(x=factor(c(2,4,5,6))) df$x <- factor(df$x, levels = 7:1) table(df$x) 7 6 5 4 3 2 1 0 1 1 1 0 1 0