group_by by a vector of characters using tidy evaluation semantics
问题 I used to do it, using group_by_ library(dplyr) group_by <- c('cyl', 'vs') mtcars %>% group_by_(.dots = group_by) %>% summarise(gear = mean(gear)) but now group_by_ is deprecated. I don't know how to do it using the tidy evaluation framework. 回答1: There is group_by_at variant of group_by : library(dplyr) group_by <- c('cyl', 'vs') mtcars %>% group_by_at(group_by) %>% summarise(gear = mean(gear)) Above it's simplified version of generalized: mtcars %>% group_by_at(vars(one_of(group_by))) %>%