select_which: Select columns satisfying a condition

Description Usage Arguments Value Examples

View source: R/select_which.R

Description

Select columns satisfying a condition

Usage

1
select_which(DT, Which, .and.dots = NULL, checkDT = TRUE)

Arguments

DT

A data.table.

Which

A function that takes a vector and returns TRUE or FALSE. TRUE columns are selected.

.and.dots

Optional extra columns to include. May be a character vector of names(DT) or numeric (positions) or logical. If provided, the columns so added (if they do not satisfy Which) will be after all the columns Which do so satisfy.

checkDT

If TRUE (the default), an informative error message is provided if DT is not a data.table.

Value

DT with the selected variables.

Examples

1
2
3
4
5
library(data.table)
DT <- data.table(x = 1:5,
                 y = letters[1:5],
                 AB = c(NA, TRUE, FALSE))
select_which(DT, anyNA, .and.dots = "y")

hutils documentation built on Nov. 1, 2018, 5:05 p.m.