Subset a data.table
with random subsampling within by
groups
subsetDT(DT, by, doSubset = TRUE, indices = FALSE)
DT | A |
---|---|
by | Character vector of column names to use for groups |
doSubset | Logical or numeric indicating the number of subsamples to use |
indices | Logical. If |
library(data.table) dt <- data.table(Lett = sample(LETTERS, replace = TRUE, size = 1000), Nums = 1:100) dt1 <- subsetDT(dt, by = "Lett", doSubset = 3)#>