KH.changeColName: Change name of columns in a data set

Description Usage Arguments Value See Also Examples

View source: R/DataSet.R

Description

Change name of columns in a data set

Usage

1
KH.changeColName(DT, currentTitles, newTitles)

Arguments

DT

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

currentTitles

character. Vector of current column names.

newTitles

character. Vector of new names after renaming.

Value

data.table. The same data object as input with name of columns changed.

See Also

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

Examples

 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"
}

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