我感觉我快失去理智了。这应该有效吧?
选择在数据集中通过管道传输的变量。我收到的错误是
Error: object 'cyl' not found
table_fun = function(data, grouping_var){
data %>%
select(grouping_var)%>%
group_by(grouping_var)%>%
summarise(count = n())
}
table_fun(mtcars, cyl)
table_fun = function(data, grouping_var){
grouping_var <- deparse(substitute(grouping_var))
data %>%
select(data[[grouping_var]])%>%
group_by(data[[grouping_var]])%>%
summarise(count = n())
}