Quickly unnest vectors nested in list columns. Still experimental (has some potentially unexpected behavior in some situations)!

dt_hoist(dt_, ...)

Arguments

dt_

the data table to unnest

...

the columns to unnest (must all be the sample length when unnested); use bare names of the variables

Examples

library(data.table) dt <- data.table( x = rnorm(1e5), y = runif(1e5), nested1 = lapply(1:10, sample, 10, replace = TRUE), nested2 = lapply(c("thing1", "thing2"), sample, 10, replace = TRUE), id = 1:1e5 ) dt_hoist(dt, nested1, nested2, by = id)
#> The following columns were dropped because they are list-columns (but not being hoisted):
#> x y V1 V2 by #> 1: -0.8366140 0.3524109 1 thing1 1 #> 2: -0.8366140 0.3524109 1 thing1 1 #> 3: -0.8366140 0.3524109 1 thing1 1 #> 4: -0.8366140 0.3524109 1 thing1 1 #> 5: -0.8366140 0.3524109 1 thing1 1 #> --- #> 999996: 0.3999232 0.4907574 7 thing2 100000 #> 999997: 0.3999232 0.4907574 5 thing2 100000 #> 999998: 0.3999232 0.4907574 4 thing2 100000 #> 999999: 0.3999232 0.4907574 4 thing2 100000 #> 1000000: 0.3999232 0.4907574 1 thing2 100000