📜  colwise dplyr - 任何代码示例

📅  最后修改于: 2022-03-11 14:58:19.604000             🧑  作者: Mango

代码示例1
df <- data.frame(g = c(1, 1, 2), x = c(-1, 1, 3), y = c(-1, -4, -9))
df %>%
  group_by(g) %>%
  summarise(across(where(is.numeric), sum))
#> `summarise()` ungrouping output (override with `.groups` argument)
#> # A tibble: 2 x 3
#>       g     x     y
#>     
#> 1     1     0    -5
#> 2     2     3    -9