Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

unnest

Unnest List Columns


Description

Transforms list columns to separate columns, possibly by reference. The original columns are removed from the returned table. All non-atomic objects in the list columns are expand to new list column.

Usage

unnest(x, cols, prefix = NULL)

Arguments

x

(data.table::data.table())
data.table::data.table() with columns to unnest.

cols

(character())
Column names of list columns to operate on.

prefix

(logical(1) | character(1))
String to prefix the new column names with. Use "{col}" (without the quotes) as placeholder for the original column name.

Value

Examples

x = data.table::data.table(
  id = 1:2,
  value = list(list(a = 1, b = 2), list(a = 2, b = 2))
)
print(x)
unnest(data.table::copy(x), "value")
unnest(data.table::copy(x), "value", prefix = "{col}.")

mlr3misc

Helper Functions for 'mlr3'

v0.10.0
LGPL-3
Authors
Michel Lang [cre, aut] (<https://orcid.org/0000-0001-9754-0393>), Patrick Schratz [aut] (<https://orcid.org/0000-0003-0748-6624>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.