mytable <- function(x, group) { x %>% group_by({{group}}) %>% summarise(n = n()) } mytable(iris, Species)