Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

receiving the following error message: Error in mutate_impl(.data, dots) : Evaluation error: argument "no" is missing, with no default.

 mutate(x,perfLev= ifelse(SS< 1438, "Below Basic",
                   ifelse(SS>= 1439 & SS <= 1499, "Basic",
                   ifelse(SS >= 1500 & SS <= 1545, "Proficient",
                   ifelse(SS >= 1546, "Advanced")))))
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
199 views
Welcome To Ask or Share your Answers For Others

1 Answer

Using comments by Make212 and Renu, here's one option for fixing it:

library(dplyr)
mutate(x,
       perfLev = case_when(
         SS <  1438              ~ "Below Basic",
         SS >= 1439 & SS <= 1499 ~ "Basic",
         SS >= 1500 & SS <= 1545 ~ "Proficient",
         SS >= 1546              ~ "Advanced",
         TRUE                    ~ "huh?"
       ) )

I added a "default" (TRUE), which is generally good (explicit code). Note that if you do not include the TRUE, then it would get an NA value, in case that's what you want. I can see it happening here if any of the following are true:

  • is.na(SS)
  • SS >= 1438 & SS < 1439
  • SS > 1499 & SS < 1500
  • SS > 1545 & SS < 1546

You may not need it if NA is acceptable and you are guaranteed of SS's integrality.

This code is equivalent to a slight fix to your code:

mutate(x,
       perfLev = 
         ifelse(SS < 1438, "Below Basic",
                ifelse(SS >= 1439 & SS <= 1499, "Basic",
                       ifelse(SS >= 1500 & SS <= 1545, "Proficient",
                              ifelse(SS >= 1546, "Advanced", "huh?"))))
       )

Indentation for style/clarity only.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...