dplyr: How to use group_by inside a function?

For programming, group_by_ is the counterpart to group_by: library(dplyr) mytable <- function(x, …) x %>% group_by_(…) %>% summarise(n = n()) mytable(iris, “Species”) # or iris %>% mytable(“Species”) which gives: Species n 1 setosa 50 2 versicolor 50 3 virginica 50 Update At the time this was written dplyr used %.% which is what was originally … Read more