R:如何总结不同功能的不同变量?

时间:2019-08-30 19:29:27

标签: r

我有4个不同大小的列名向量

  • 要分组的列
  • 总结均值的列
  • 汇总最大值的列
  • 汇总分钟的列

我尝试做

col.avg <- c("mpg","wt","hp")
col.max <- c("mpg","hp","wt","qsec")
col.min <- c("mpg","hp","wt","qsec")
col.group <- c("cyl","vs","am","gear","carb")

test<- mtcars %>% 
                 group_by(.dots = col.group) %>% 
                 summarize_at(.vars = col.min, .funs = c(min= "min")) %>% 
                 summarize_at(.vars = col.mean, .funs = c(mean= "mean")) %>% 
                 summarize_at(.vars = col.max, .funs = c(max= "max"))
设置了mtcars的

,但它不允许我输入多个summary_at字符串。有什么办法可以将summary_at合并为一个?

0 个答案:

没有答案