nest_by: Nest by one or more variables

Description Usage Arguments Details Value Examples

Description

\badgeexperimental

Usage

1
2
3
4
5
nest_by(.data, ..., .key = "data")

nest_by_at(.data, ..., .key = "data")

nest_by_if(.data, ..., .key = "data")

Arguments

.data

a tbl

...

Variables to nest by. nest_by passes them to group_by(), nest_by_at passes them to group_by_at() and nest_by_if() passes them to group_by_if()

.key

the name of the list column

Details

Conceptually, nest_by is the same as group_by() + tidyr::nest().

Value

A tbl with one row per unique combination of the grouping variables. The first columns are the grouping variables, followed by a list column of tibbles with matching rows of the remaining columns.

Examples

1
2
3
4
5
6
7
8
starwars %>%
  nest_by(species, homeworld)

starwars %>%
  nest_by_at(vars(ends_with("_color")))

starwars %>%
  nest_by_if(is.numeric)

olascodgreat/samife documentation built on May 13, 2019, 6:11 p.m.