mutate a column within a dplyr pype only on a subset of rows specified by a condition Retrieved from a StackOverflow answer (https://stackoverflow.com/a/34170176/6871135)
pr_mutate_when(data, ...)
data | a |
---|---|
... | expression to be evaluated to filter on rows |
data frame
DETAILS
# NOT RUN { library(magrittr) mtcars %>% mutate_when( mpg > 22, list(cyl = 100), disp == 160, list(cyl = 200)) # }