mercredi 24 février 2021

How to use an if else statement and not apply it or skip when a value from the column is equal to X in R?

For example I have a column of values

 unique(df$Animals)

 "Giraffe","Elephant", "Lion","Cheetah","Dingo"

I want the conditional statement to completely skip when df$Animal is equal to "Dingo"

 df$Spotted<-ifelse(!is.na(df$Animals),
                         "Yes", "No")

Normally the script would assign Yes to all values which i am ok, but i don't want it to even read or go over when it is Dingo.

Aucun commentaire:

Enregistrer un commentaire