Does anyone know if its possible to use the base R "ifelse" statement for multiple range conditions at once? Is this easier with dplyr?
If df$var1 < 5 and df$var2 < 5 , then df$var3 = "a"
If df$var1 > 5 and df$var1<10 AND df$var2>5 and df$var2<10, then df$var3 = "b"
If df$var1 >10 and df$var2 >10, then df$var3 = "c"
Can all this be combined into a single ifelse statement?
Thanks
Aucun commentaire:
Enregistrer un commentaire