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
We can use .$
.$
mtcars %>% mutate(cg = case_when(.$carb <= 2 ~ "low", .$carb > 2 ~ "high")) %>% .$cg %>% table() # high low # 15 17