I have a SPSS code for recoding variables that I'm trying to replicate in R.
The code is:
recode variable (1 = 7) (2 = 5) (3 = 4) (4 = 3) (5 = 1) (6 = 2).
How can I replicate this is R (better if it's a short piece of code).
Thx!
vec <- c(1, 2, 3, 4, 5, 6)
dplyr::recode(vec,
`1` = 7,
`2` = 5,
`3` = 4,
`4` = 3,
`5` = 1,
`6` = 2)