unnest: Expand list-columns back into rows

View source: R/nest.R

unnestR Documentation

Expand list-columns back into rows

Description

unnest() is the inverse of nest(). Each element of a list-column is expanded into rows, and the other columns are repeated to match. Elements may be data frames (their columns are added) or atomic vectors (the values are stored under the list-column's own name). Rows whose element is empty are dropped.

Usage

unnest(data, cols)

Arguments

data

A data frame with one or more list-columns.

cols

Character vector of list-columns to expand. When several are given, their elements must have matching lengths within each row.

Value

A basetable with one row per element.

See Also

nest()

Examples

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

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