Description Usage Arguments Examples
Use the superpowered dplyr::summarise()
with explicit
grouping and checks for length-one results per group.
1 2 3 4 5 6 7 |
.data |
A data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr). See Methods, below, for more details. |
... |
< The value can be:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | library(dplyr, warn.conflicts = FALSE)
# default drops grouping after sumr
starwars %>%
group_by(species) %>%
sumr(mass = mean(mass))
# can peel back grouping structure
# with each sumr_peel()
starwars %>%
group_by(gender, species) %>%
sumr_peel(mass = mean(mass, na.rm = TRUE)) %>%
sumr_peel(mass = mean(mass, na.rm = TRUE))
# can also keep grouping structure
starwars %>%
group_by(species) %>%
sumr_keep(mass = mean(mass))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.