Learn R Programming

tidytable (version 0.10.2)

unnest_wider: 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

Run this code
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 = "_")

Run the code above in your browser using DataLab