Quickly unnest data tables, particularly those nested by dt_nest().

dt_unnest(dt_, col, ...)

Arguments

dt_

the data table to unnest

col

the column to unnest

...

any of the other variables in the nested table that you want to keep in the unnested table. Bare variable names. If none are provided, all variables are kept.

Examples

library(data.table) dt <- data.table( x = rnorm(1e5), y = runif(1e5), grp = sample(1L:3L, 1e5, replace = TRUE) ) nested <- dt_nest(dt, grp) dt_unnest(nested, col = data)
#> grp x y #> <int> <num> <num> #> 1: 1 1.0132525 0.02937715 #> 2: 1 1.3222125 0.17566096 #> 3: 1 0.5065119 0.06658542 #> 4: 1 -0.9279822 0.55996602 #> 5: 1 0.7179084 0.85645944 #> --- #> 99996: 3 0.5534343 0.82439307 #> 99997: 3 -0.5466994 0.59113375 #> 99998: 3 0.0279944 0.50978427 #> 99999: 3 1.9397046 0.40044357 #> 100000: 3 1.4679262 0.38763369