Description Usage Arguments Details Value Author(s) See Also Examples
Transform a character vector to another one with good names for data.frames header following several rules.
1 2 | tidy_rname(char, ascii = TRUE, no_dots = TRUE, no_duplicate = TRUE,
max_size = 16, lowercase = TRUE)
|
char |
A character vector with the original columns names. |
ascii |
Boolean. Only produce ASCII char. Default is |
no_dots |
Boolean. Replace dots by underscores. Default is |
no_duplicate |
Boolean. If there is a duplicate, add a number at the end of the name. |
max_size |
Integer. Number max of character. If 0, no limits. Will not cut words < of 8 letters. Default is 16. Will keep the first letters and the last ones (a least 3) |
lowercase |
Boolean. Change to lower cases. Default is |
The rules applied are :
rules from official doc : use the function make.names
rules of good practice
only ASCII character
don't use dots because they have a special meaning in R
avoid duplicates
don't use to long name (less than 16 char).
should be only lower cases
A character vector.
Joris Muller
This function is used by descvars_skeleton
to produce
the column rname. The base make.names
function does a part of
the work.
1 2 3 4 | bad_names <- c("white space", "multiples...dots..", "duplicate",
"duplicate", "$p<c3><a9>cial char", "looooooooognameeeeeeee")
transformed_names <- tidy_rname(bad_names)
transformed_names
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.