I am trying to apply some if and elseif statements to a couple of vectors to create a new variable.
C <- c(Standard, Micro, Nurse)
P <- c(Standard, NA, NA)
DF.2 <- DF.1 %>%
mutate("Category" = if_else(condition = `C`=="Standard" | `P`=="Standard",
true = "Standard",
if_else(condition = C` == "Micro" |
`P`=="Micro",
true = "Micro",
if_else(condition = `C` == "Nurse",
true = "Nurse",
false = "Other"))))
When I run this code I expect to have a new vector of:
Category <- c(Standard, Micro, Nurse)
It seems to be picking up the standard and micro, but not the nurse.
Aucun commentaire:
Enregistrer un commentaire