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.

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

:: character(1)
String to prefix the new column names with.

Value

(data.table::data.table()).

Examples

x = data.table::data.table( id = 1:2, value = list(list(a = 1, b = 2), list(a = 2, b = 2)) ) print(x)
#> id value #> 1: 1 <list> #> 2: 2 <list>
unnest(x, "value")
#> id a b #> 1: 1 1 2 #> 2: 2 2 2