It seems dplyr::case_when doesn\'t behave as other commands in a dplyr::mutate call. For instance:
dplyr::case_when
dplyr::mutate
library(dplyr) case_when(mtcars
As of version 0.7.0 of dplyr, case_when works within mutate as follows:
0.7.0
dplyr
case_when
mutate
library(dplyr) # >= 0.7.0 mtcars %>% mutate(cg = case_when(carb <= 2 ~ "low", carb > 2 ~ "high"))
For more information: http://dplyr.tidyverse.org/reference/case_when.html