I'm getting NA returned when using dplyr
s casewhen
in the mutate
function. I like casewhen
because I don't have to use the long ifelse
statements if I want to FALSE value to be the default of the original value. Is this not the point of using casewhen
? This code results in the NAs.
mtcars %>%
as_tibble() %>%
mutate(vs = case_when(carb == 4 ~ +5))
I'd like to add 1 to vs column when values of carb are 4. Thanks.