Description Usage Arguments Value Examples
Clean the column names of a data.frame
or data.table
.
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, ...)
|
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). |
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.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.