KH.dropColsByName: Drop column or columns from a data.table by using the names.

Description Usage Arguments Value See Also Examples

View source: R/DataSet.R

Description

Drop column or columns from a data.table by using the names.

Usage

1
KH.dropColsByName(DT, currentTitles)

Arguments

DT

data.table Two dimension data object which colnames(x) is meaningful.

currentTitles

character. Vector of current column names.

Value

data.table. The same object as input with columns removed.

See Also

Other DataSets: KH.changeColName, KH.loadCSV, KH.loadXlsx

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
set.seed(1000)
library(data.table)
d <- data.table(
group = sample(LETTERS[1:3], 10, replace = TRUE),
integer = rnorm(10, 5, 1),
integer1 = rnorm(10, 5, 1),
integer2 = rnorm(10, 5, 1),
decimal = rnorm(10, 5, 1)
)
colnames(d)
#[1] "group" "integer" "integer1" "integer2" "decimal"
d <- KH.dropColsByName(d, 'integer')
colnames(d)
#[1] "group" "integer1" "integer2" "decimal"

d <- KH.dropColsByName(d, c('integer1', 'integer2'))
colnames(d)
#[1] "group" "decimal"

ks465/r-utils documentation built on May 23, 2019, 5:07 p.m.