unnest_wider: Unnest a list-column of vectors into a wide data frame

View source: R/unnest_wider.R

unnest_widerR Documentation

Unnest a list-column of vectors into a wide data frame

Description

Unnest a list-column of vectors into a wide data frame

Usage

unnest_wider(
  .df,
  col,
  names_sep = NULL,
  simplify = NULL,
  names_repair = "check_unique",
  ptype = NULL,
  transform = NULL
)

Arguments

.df

A data.table or data.frame

col

Column to unnest

names_sep

If NULL, the default, the names will be left as they are. If a string, the inner and outer names will be pasted together with names_sep as the separator.

simplify

Currently not supported. Errors if not NULL.

names_repair

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

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)
)

# Automatically creates names
df %>% unnest_wider(y)

# But you can provide names_sep for increased naming control
df %>% unnest_wider(y, names_sep = "_")

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