Description Usage Arguments Value Examples
Each of these functions first group the data using dplyr::group_by()
and then:
mutate_groups()
: Apply calculations using dplyr::mutate()
.
transmute_groups()
: Apply calculations using dplyr::transmute()
.
summarise_groups()
: Summarise the data by applying calculations using dplyr::summarise()
.
arrange_groups()
: Order the data using dplyr::arrange()
with .by_group = TRUE
.
The respective output is ungrouped.
1 2 3 4 5 6 7 8 9 | mutate_groups(.data, .groups, ...)
summarise_groups(.data, .groups, ...)
summarize_groups(.data, .groups, ...)
transmute_groups(.data, .groups, ...)
arrange_groups(.data, .groups, ...)
|
.data |
A |
.groups |
|
... |
Arguments to pass onto the respective function. |
A tbl_spark
or a data.frame
depending on the input, .data
.
1 2 3 4 5 6 7 8 | mtcars %>%
mutate_groups(.groups = c("am", "cyl"), avgMpg = mean(mpg))
mtcars %>%
summarise_groups(.groups = c("am", "cyl"), avgMpg = mean(mpg))
# Additional arguments can still be passed to the dplyr functions
mtcars %>%
mutate_groups(.groups = "am", avgMpg = mean(mpg), .before = mpg)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.