Created
September 1, 2020 10:46
-
-
Save keithmcnulty/946c07c2483f130fac8cd8108499e0a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
penguin_stats <- penguins %>% | |
dplyr::group_by(species) %>% | |
dplyr::summarise(across(ends_with("mm"), | |
list(mean = ~mean(.x, na.rm = TRUE), sd = ~sd(.x, na.rm = TRUE)), # name summary functions | |
.names = "{gsub('_|_mm', '', col)}_{fn}")) # structure for summarised column names | |
penguin_stats | |
# A tibble: 3 x 7 | |
species billlength_mean billlength_sd billdepth_mean billdepth_sd flipperlength_mean flipperlength_sd | |
<fct> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> | |
1 Adelie 38.8 2.66 18.3 1.22 190. 6.54 | |
2 Chinstrap 48.8 3.34 18.4 1.14 196. 7.13 | |
3 Gentoo 47.5 3.08 15.0 0.981 217. 6.48 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment