Reports how many tables the rows were split into, and how many rows each of them holds.
Usage
# S3 method for class 'data.table'
split(x, f, drop = FALSE, ...)Arguments
- x
The data table to split.
- f
The grouping factor, as in
base::split().data.table's ownby=is the usual way to give it instead.- drop
Whether to drop unused levels, as in
base::split().- ...
All other arguments of
data.table'ssplit()method, i.e.by,sorted,keep.byandflatten.
Examples
dt <- data.table::data.table(g = c("a", "a", "b"), v = 1:3)
split(dt, by = "g")
#> split: 3 rows into 2 tables (a: 2 rows, b: one row)
#> $a
#> g v
#> <char> <int>
#> 1: a 1
#> 2: a 2
#>
#> $b
#> g v
#> <char> <int>
#> 1: b 3
#>
