0

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)
divibisan
  • 11,659
  • 11
  • 40
  • 58
user3067851
  • 524
  • 1
  • 6
  • 20
  • Hi @user3067851, it seems I incorrectly assumed your factors tag referred to Factor programming language. Please correct your title in that case. – 1010 Jun 15 '15 at 16:56
  • 2
    `as.factor()` doesn't have a `levels=` parameter, but `factor()` does; use that instead. – MrFlick Jun 15 '15 at 17:28
  • Possible duplicate of [Idiom for ifelse-style recoding for multiple categories](https://stackoverflow.com/questions/10431403/idiom-for-ifelse-style-recoding-for-multiple-categories) – divibisan Sep 06 '18 at 20:22

0 Answers0