在以前版本的 dplyr 中,如果我想使用 获取行计数以及其他汇总值summarise(),我可以执行类似的操作
library(tidyverse)\n\ndf <- tibble(\n group = c("A", "A", "B", "B", "C"),\n value = c(1, 2, 3, 4, 5)\n)\n\ndf %>%\n group_by(group) %>% \n summarise(total = sum(value), count = n())\n\n`summarise()` ungrouping output (override with `.groups` argument)\n\n# A tibble: 3 x 3\n group total count\n <chr> <dbl> <int>\n1 A 3 2\n2 B 7 2\n3 C 5 1\nRun Code Online (Sandbox Code Playgroud)\n我使用新函数获得相同输出的本能across()是
df %>%\n group_by(group) %>% \n summarise(across(value, list(sum = sum, count = n)))\nError: Problem with `summarise()` …Run Code Online (Sandbox Code Playgroud)