I'm new to using "R" (used to using SPSS), I am having trouble recoding values for a variable, given multiple responses or cases for that variable. I am trying to use an "ifelse" function to achieve this, but I cannot make the function work for modifying more than two values for the variables. I want to recode responses for a variable with multiple cases. Currently the data includes #'s 1, 2, 3, 4 and I want to recode these numbers like this: (1=0.6) (2=1.2) (3=2.5) (4=1.8).
I am trying to use an "ifelse" function to achieve this, but I cannot make the function work for modifying more than two different values for the specific variable.
ChildPABase19_test$Predilection_1 <- ifelse(ChildPABase19_test$Predilection_1==1, 0.6, ifelse(ChildPABase19_test$Predilection_1==2, 1.2, ifelse(ChildPABase19_test$Predilection_1==3, 2.5, ifelse(ChildPABase19_test$Predilection_1==4, 1.8))
I would like all of the data in the column for variable Predilection_1 to be recoded with 0.6, 1.2, 2.5, 1.8, but I keep getting the error: argument "no" is missing, with no default. Any ideas of how I can modify this code would be greatly appreciated!
Aucun commentaire:
Enregistrer un commentaire