I have a column with subject numbers and I want to add a column "group" based on the subject number (each subject belongs to one of 3 different groups). The subjects were assigned randomly to the groups, so I cannot use a logical operator such as ">" but I have to specify the values of all the subjects individually. I came up with this code but apparently it fails, because in the output in the column "group" I get mostly NA's. In addition, I also get the warning message "longer object length is not a multiple of shorter object length".
df$group <- ifelse(df$Subject == c("20","113","504"),"silent", ifelse(df$Subject == c("283","440","581), "active", ifelse(df$Subject == c("481","503","536), "training","NA")))
Aucun commentaire:
Enregistrer un commentaire