mercredi 8 juillet 2015

If else issue; fail to assign category to integer category in R

Data

I want to get Category name in the category column using the logic that I have incorporated in the code below. However, it breaks and produces an error.

  • Rating variable is an integer.

Warning message: In if (nps$Rating <= 6) { : the condition has length > 1 and only the first element will be used

if(nps$Rating<=6){nps$npsCAT <- "Detractor" } else if (nps$Rating>6 & nps$Rating<9){nps$npsCAT <- "Passive"} else {nps$npsCAT <- "Promoter"}

Aucun commentaire:

Enregistrer un commentaire