Some functions (e.g., getJobPars
, getJobResources
or reduceResultsDataTable
return a data.table
with columns of type list
.
These columns can be unnested/unwrapped with this function.
The contents of these columns will be transformed to a data.table
and cbind
-ed
to the input data.frame x
, replacing the original nested column.
unwrap(x, cols = NULL, sep = NULL) flatten(x, cols = NULL, sep = NULL)
x | [ |
---|---|
cols | [ |
sep | [ |
[data.table
].
There is a name clash with function flatten
in package purrr.
The function flatten
is discouraged to use for this reason in favor of unwrap
.
x = data.table::data.table( id = 1:3, values = list(list(a = 1, b = 3), list(a = 2, b = 2), list(a = 3)) ) unwrap(x)#> id a b #> 1: 1 1 3 #> 2: 2 2 2 #> 3: 3 3 NAunwrap(x, sep = ".")#> id values.a values.b #> 1: 1 1 3 #> 2: 2 2 2 #> 3: 3 3 NA