jeudi 3 août 2017

IF statment not functioning - R

I have a variable sleptim, conatins number of hours slept which ranges from 2 hrs to 19 hrs. The result of the new categorical variable is not functioning well . Help plz

for (i in 500: 1500)
{
    if(question4$sleptim1[i]<6) 
    {question4$sleptim1[i] <- "Below Normal"}


    else if(question4$sleptim1[i]>9)
    {question4$sleptim1[i] <- "Above Normal"}


    else
    {question4$sleptim1[i] <- "Normal"}
}

Aucun commentaire:

Enregistrer un commentaire