Skip to content

Instantly share code, notes, and snippets.

@keithmcnulty
Created July 16, 2020 11:38
Show Gist options
  • Select an option

  • Save keithmcnulty/12b21b640583906b794178e49bc2607b to your computer and use it in GitHub Desktop.

Select an option

Save keithmcnulty/12b21b640583906b794178e49bc2607b to your computer and use it in GitHub Desktop.
mtcars %>%
dplyr::group_by(cyl) %>%
dplyr::summarise(across(starts_with("d"),
list(mean = mean, median = median),
.names = "{fn}_of_{col}"))
#> # A tibble: 3 x 5
#> cyl mean_of_disp median_of_disp mean_of_drat median_of_drat
#> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 4 105. 108 4.07 4.08
#> 2 6 183. 168. 3.59 3.9
#> 3 8 353. 350. 3.23 3.12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment