Description Usage Arguments Value See Also Examples
Change name of columns in a data set
1 | KH.changeColName(DT, currentTitles, newTitles)
|
DT |
data.table. Two dimension data object which |
currentTitles |
character. Vector of current column names. |
newTitles |
character. Vector of new names after renaming. |
data.table. The same data object as input with name of columns changed.
Other DataSets: KH.dropColsByName
,
KH.loadCSV
, KH.loadXlsx
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | {
set.seed(1000)
library(data.table)
d <- data.table(
group = sample(LETTERS[1:3], 10, replace = TRUE),
integer = rnorm(10, 5, 1),
decimal = rnorm(10, 5, 1)
)
colnames(d)
#[1] "group" "integer" "decimal"
d <- KH.changeColName(d, 'integer', 'zeroPrecision')
colnames(d)
#[1] "group" "zeroPrecision" "decimal"
d <- KH.changeColName(d, c('group', 'decimal'), c('newGroup', 'float'))
colnames(d)
#[1] "newGroup" "zeroPrecision" "float"
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.