Skip to content

Instantly share code, notes, and snippets.

@dgrtwo
Last active August 21, 2016 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dgrtwo/527045ccdb06ac5754333f44c9c831a7 to your computer and use it in GitHub Desktop.
Save dgrtwo/527045ccdb06ac5754333f44c9c831a7 to your computer and use it in GitHub Desktop.
grouply <- function(f, ...) {
groups <- lazyeval::lazy_dots(...)
function(tbl, ...) {
dplyr::group_by_(tbl, .dots = groups) %>%
f(...) %>%
dplyr::ungroup()
}
}
mtcars %>% grouply(mutate, cyl, am)(n = n())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment