Learn R Programming

popEpi (version 0.3.1)

setcolsnull: Delete data.table columns if there

Description

Deletes columns in a data.table conveniently. May only delete columns that are found silently. Sometimes useful in e.g. on.exit expressions.

Usage

setcolsnull(DT = NULL, delete = NULL, keep = NULL, colorder = FALSE, soft = TRUE)

Arguments

DT
a data.table
delete
a character vector of column names to be deleted
keep
a character vector of column names to keep; the rest will be removed; keep overrides delete
colorder
logical; if TRUE, also does setcolorder using keep
soft
logical; if TRUE, does not cause an error if any variable name in keep or delete is missing; soft = FALSE useful for programming sometimes