-1

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!

neilfws
  • 32,751
  • 5
  • 50
  • 63
EGM8686
  • 1,492
  • 1
  • 11
  • 22

1 Answers1

0
vec <- c(1, 2, 3, 4, 5, 6)
dplyr::recode(vec, 
       `1` = 7,
       `2` = 5,
       `3` = 4,
       `4` = 3,
       `5` = 1,
       `6` = 2)
Croote
  • 1,382
  • 1
  • 7
  • 15