Aim is to simulate the SPSS recode procedure in R. The copy-command is hard to translate.
In SPSS I have code as
RECODE A (1,2 = 1) (3,4 = copy) (8 thru hi = 3) (else = 1) into B.
Applied over A which looks like
A <- c(1,2,3,4,5,NA,7,8,9)
i get the following (SPSS) result:
A = 1,1,3,4,1,1,1,3,3
In R a similar code would look like this:
B <- Recode(A, recodes = ("c(1,2) = 1; c(3,4) = c(3,4); c(8,9) = 3; else = 1"), as.numeric.result = TRUE)
A = 1,1,3,4,1,1,1,3,3
The general Problem is to indicate the Values in the SPSS-copy statement. Here I wrote c(3,4) = c(3,4) - of course, it doesn´t work.
In SPSS also exists the possibility to say else = copy what returns the same output as R do.
Does anyone have a R function that works in the same way as SPSS?