setcolsnull {popEpi}R Documentation

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

Value

Always returns 'NULL' invisibly. This function is called for its side effects.

Author(s)

Joonas Miettinen


[Package popEpi version 0.4.12 Index]