group_map. | R Documentation |
dplyr::group_map returns an unnamed list, but a named list is often handy https://github.com/tidyverse/dplyr/issues/4223#issuecomment-469269857
group_map.(.data, .f, ..., .keep = FALSE)
.data |
a grouped tibble |
.f |
a function of formula to apply to each group.
If a function, it is used as is. It should have at least 2 formal arguments.
If a formula, e.g. ~ head(.x), it is converted to a function.
In the formula, you can use:
* |
a list of elemnts returned by .f
over the grouped elements in
.data
# no names
iris |> group_by(Species) |> group_map(~ nrow(.x))
# with names
iris |> group_by(Species) |> group_map.(~ nrow(.x))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.