nest: Nest rows into a list-column of tables

View source: R/nest.R

nestR Documentation

Nest rows into a list-column of tables

Description

nest() collapses the rows of each group into a data frame and stores those data frames in a single list-column, giving one row per group. Groups appear in order of first occurrence. Missing values in by form their own group.

Usage

nest(data, by, name = "data")

Arguments

data

A data frame.

by

Character vector of grouping columns.

name

Name of the new list-column.

Value

A basetable with the by columns and one list-column holding the remaining columns of each group as a data frame.

See Also

unnest(), split()

Examples

nested <- nest(data.frame(g = c("a", "a", "b"), x = 1:3), by = "g")
nested
nested$data[[1]]

basetable documentation built on Nov. 14, 2026, 1:08 a.m.