dt_nest.Rd
Quickly nest data tables (similar to dplyr::group_nest()
).
dt_nest(dt_, ..., .key = "data")
the data table to nest
the variables to group by
the name of the list column; default is "data"
A data.table with a list column containing data.tables
library(data.table)
dt <- data.table(
x = rnorm(1e5),
y = runif(1e5),
grp = sample(1L:3L, 1e5, replace = TRUE)
)
dt_nest(dt, grp)
#> Key: <grp>
#> grp data
#> <int> <list>
#> 1: 1 <data.table[33454x2]>
#> 2: 2 <data.table[33135x2]>
#> 3: 3 <data.table[33411x2]>