with_groups | R Documentation |
This was an experimental function that allows you to modify the grouping
variables for a single operation; it is superseded in favour of using the
.by
argument to individual verbs.
with_groups(.data, .groups, .f, ...)
.data |
A data frame |
.groups |
< Use |
.f |
Function to apply to regrouped data.
Supports purrr-style |
... |
Additional arguments passed on to |
df <- tibble(g = c(1, 1, 2, 2, 3), x = runif(5))
# Old
df %>%
with_groups(g, mutate, x_mean = mean(x))
# New
df %>% mutate(x_mean = mean(x), .by = g)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.