subsetDT: Subset a 'data.table' with random subsampling within 'by'...

Description Usage Arguments Examples

Description

Subset a data.table with random subsampling within by groups

Usage

1
subsetDT(DT, by, doSubset = TRUE, indices = FALSE)

Arguments

DT

A data.table

by

Character vector of column names to use for groups

doSubset

Logical or numeric indicating the number of subsamples to use

indices

Logical. If TRUE, this will return vector of row indices only. Defaults to FALSE, i.e., return the subsampled data.table

Examples

1
2
3
library(data.table)
dt <- data.table(Lett = sample(LETTERS, replace = TRUE, size = 1000), Nums = 1:100)
dt1 <- subsetDT(dt, by = "Lett", doSubset = 3)

PredictiveEcology/LandR documentation built on Jan. 24, 2021, 12:52 a.m.