Skip to content

Instantly share code, notes, and snippets.

@lurodrigo
Created March 5, 2018 20:36
Show Gist options
  • Save lurodrigo/c0b7bd9590bc6e0ade00016010f0a29b to your computer and use it in GitHub Desktop.
Save lurodrigo/c0b7bd9590bc6e0ade00016010f0a29b to your computer and use it in GitHub Desktop.
Multiple summarise() statements
ms = function(.data, ...) {
dots = quos(...)
map(dots, ~ call_modify(., .data = .data) %>% eval_tidy()) %>%
reduce(function(tb1, tb2) {
for (newcol in setdiff(names(tb2), names(tb1))) {
tb1[[newcol]] = tb2[[newcol]]
}
tb1
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment