drop_col: Drop column or columns

Description Usage Arguments Value Examples

View source: R/drop_col.R

Description

Drop column or columns

Usage

1
2
3
drop_col(DT, var, checkDT = TRUE)

drop_cols(DT, vars, checkDT = TRUE)

Arguments

DT

A data.table.

var

Quoted column to drop.

checkDT

Should the function check DT is a data.table?

vars

Character vector of columns to drop. Only the intersection is dropped; if any vars are not in names(DT), no warning is emitted.

Value

DT with specified columns removed.

Examples

1
2
3
4
5
6
if (requireNamespace("data.table", quietly = TRUE)) {
  library(data.table)
  DT <- data.table(x = 1, y = 2, z = 3)
  
  drop_col(DT, "x")
}

hutils documentation built on Aug. 20, 2018, 9:04 a.m.