I have a dataset, "cipe", and am trying to create a new variable, "case", if any of the following criteria "htn, "sle", "apls", "diabetes", "ckd" are met
The code I am using is:
cipe <- mutate(cipe, case == ifelse(htn == 1, "1",
ifelse(sle == 1, "1",
ifelse(apls == 1, "1",
ifelse(diabetes == 1, "1",
ifelse(ckd == 1, "1", "0"))))))
My dataset has ~840k observations so it is not feasible to post, but when i run this code the number of "1"s in the new "case" variable is exactly equal to the number of "1"s in "htn", (should be much higher), so the other tests are not being assessed. Any help would be great. Thanks
Aucun commentaire:
Enregistrer un commentaire