Description Usage Arguments Value See Also Examples
Drop column or columns from a data.table by using the names.
1 | KH.dropColsByName(DT, currentTitles)
|
DT |
data.table Two dimension data object which |
currentTitles |
character. Vector of current column names. |
data.table. The same object as input with columns removed.
Other DataSets: KH.changeColName
,
KH.loadCSV
, KH.loadXlsx
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"
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.