unnest_longer: Unnest a list-column of vectors into regular columns

View source: R/unnest_longer.R

unnest_longerR Documentation

Unnest a list-column of vectors into regular columns

Description

Turns each element of a list-column into a row.

Usage

unnest_longer(
  .df,
  col,
  values_to = NULL,
  indices_to = NULL,
  indices_include = NULL,
  keep_empty = FALSE,
  names_repair = "check_unique",
  simplify = NULL,
  ptype = NULL,
  transform = NULL
)

Arguments

.df

A data.table or data.frame

col

Column to unnest

values_to

Name of column to store values

indices_to

Name of column to store indices

indices_include

Should an index column be included? Defaults to TRUE when col has inner names.

keep_empty

Return NA for any NULL elements of the list column

names_repair

Treatment of duplicate names. See ?vctrs::vec_as_names for options/details.

simplify

Currently not supported. Errors if not NULL.

ptype

Optionally a named list of ptypes declaring the desired output type of each component.

transform

Optionally a named list of transformation functions applied to each component.

Examples

df <- tidytable(
  x = 1:3,
  y = list(0, 1:3, 4:5)
)

df %>% unnest_longer(y)

tidytable documentation built on Sept. 11, 2024, 8:05 p.m.