I am fairly proficient within the Tidyverse, but have always used ifelse() instead of dplyr if_else(). I want to switch this behavior and default t
ifelse()
if_else()
I'd also add that if_else() can attribute a value in case of NA, which is a handy way of adding an extra condition.
NA
df <- data_frame(val = c(80, 90, NA, 110)) df %>% mutate(category = if_else(val < 100, 1, 2, missing = 9)) # val category # # 1 80 1 # 2 90 1 # 3 NA 9 # 4 110 2