Set factor levels using ifelse statements in R

253 views Asked by At

I am trying to use the levels argument for 4 different ifelse scenarios. However, R isn't recognizing 'levels' as an argument. I tried changing the parenthesis to different locations but still doesn't work. Any help would be appreciated.

cgrp <- as.factor(ifelse(zperform$RISK >= 720,4,  
                       ifelse(zperform$RISK < 720 & zperform$RISK >= 660,3,  
                              ifelse(zperform$RISK < 660 & zperform$RISK >= 659,2,1
                                    ))), levels = letters)
0

There are 0 answers