Skip to content

Instantly share code, notes, and snippets.

@klmr
Last active November 21, 2017 19:47
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klmr/41326eae65642efa6d22b9b9b1358452 to your computer and use it in GitHub Desktop.
Save klmr/41326eae65642efa6d22b9b9b1358452 to your computer and use it in GitHub Desktop.
Missing `mutate_when` function for dplyr
modules::import_package('rlang', attach = TRUE)
mutate_when = function (.data, .filter, ...) {
dots = dots_definitions(...)$dots
rows = eval_tidy(enquo(.filter), .data)
.data[rows, names(dots)] =
lapply(dots, eval_tidy, data = .data[rows, , drop = FALSE])
.data
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment