drop_cols: Drop columns in 'data.table' by reference or returning a...

Description Usage Arguments Examples

View source: R/data.table_misc.R

Description

Drop columns in data.table by reference or returning a copy.

Usage

1
drop_cols(dt, cols, modify = FALSE)

Arguments

dt

data.table to process

cols

Column names to drop, vector of strings

modify

Boolean, indicating whether columns should be dropped by reference of a copy should be returned

Examples

1
2
3
4
5
6
7
8
require(data.table)
dt <- data.table(V1 = 1, V2 = 2, V3 = 3)
print(dt)
dt_dropped <- drop_cols(dt, c("V1", "V2"), modify = FALSE)
print(dt)
print(dt_dropped)
drop_cols(dt, c("V1", "V2"), modify = TRUE)
print(dt)

m-dz/mdmisc documentation built on May 22, 2019, 12:23 p.m.