clean_col_names: Clean Column Names

Description Usage Arguments Value Examples

View source: R/Cleaning.R

Description

Clean the column names of a data.frame or data.table.

Usage

1
2
3
4
5
6
7
clean_col_names(object, ...)

## S3 method for class 'data.frame'
clean_col_names(object, short = FALSE, ...)

## S3 method for class 'matrix'
clean_col_names(object, short = FALSE, ...)

Arguments

object

The object to clean names for.

...

further arguments passed to or from other methods.

short

Whether to shorten certain cleaned name replacements (logical scalar).

Value

clean_col_names.data.frame: the input object, with column names cleaned and modifed by reference.

clean_col_names.matrix: the input object, with column names cleaned and modifed.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
DF <- data.frame(
  "a[b.c]d" = 1:26, "e\\f;g1h" = letters,
  "i/j k_l+m-n.o(p)q_$_%_kl" = sample(c(TRUE, FALSE), 26, replace = TRUE),
  check.names = FALSE
)
colnames(DF)
print(methods("clean_col_names"))
DF <- clean_col_names(DF, TRUE)
colnames(DF)

DT <- data.table::data.table(
  "a[b.c]d" = 1:26, "e\\f;g1h" = letters,
  "i/j k_l+m-n.o(p)q_$_%_kl" = sample(c(TRUE, FALSE), 26, replace = TRUE)
)
colnames(DT)
clean_col_names(DT, TRUE)
colnames(DT)

KO112/KO documentation built on Oct. 2, 2020, 9:21 a.m.