dropj: Drop columns conditionally by reference

dropjR Documentation

Drop columns conditionally by reference

Description

These functions drop columns of your data.table by reference based on a selection of columns, a predicate function or a regex pattern that the column name must match.

Usage

dropj_at(DT, cols)

dropj_if(DT, .p)

dropj_grep(DT, pattern)

Arguments

DT

(data.table::data.table())
A data.table.

cols

(character() or numeric())
A vector of integer column indices or character column names.

.p

(⁠function()⁠)
A predicate function that will be applied to all columns and returns a logical vector.

pattern

(character(1))
A regular expression pattern as used by grep().

Details

dropj_at() drops column based on a vector of column indices or column names.

dropj_if() takes predicate function .p as an input that will be applied to each of the columns and returns a logical vector. It will then drop those columns for which the function returns TRUE.

dropj_grep() takes a regex pattern as input and will check if the column names match that pattern. If so, they will be dropped.

Value

(data.table::data.table())
The functions invisibly return the modified data.table.


DavidJesse21/data.table.utils documentation built on March 26, 2023, 7:19 a.m.