Skip to content

Instantly share code, notes, and snippets.

@mbannert
Created January 20, 2018 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbannert/8a232bd7c8bdbfd6bdf6ebccfc35aa70 to your computer and use it in GitHub Desktop.
Save mbannert/8a232bd7c8bdbfd6bdf6ebccfc35aa70 to your computer and use it in GitHub Desktop.
dpl_gr <- function(ds,vars){
ds %>%
group_by_(.dots = vars) %>%
summarise(n = n()) %>%
mutate(freq = n / sum(n))
}
dpl_gr(mtcars,c("am","cyl"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment