ez.clcolnames | R Documentation |
replace certain characters (all occurrence) in all column names, using regular expression and gsub(). see also ez.clcoldata
ez.clcolnames(
df,
pattern = "[[:space:][:punct:]]",
replacement = ".",
fixed = FALSE,
ignore.case = FALSE,
perl = TRUE,
col = NULL
)
df |
df |
pattern |
search |
replacement |
replacement |
fixed |
FALSE=regex mode on, TRUE=regex mode off |
ignore.case |
if FALSE, the pattern matching is case sensitive and if TRUE, case is ignored during matching. |
perl |
Perl-compatible regexps be used, without perl, [[:space:][:punct:]] works, but not [\s[:punct:]]
so seems always a good idea to turn on perl compatible. see |
col |
NULL=all columns, otherwise restricted to specified cols, eg, ( internally evaluated by eval('dplyr::select()') )
|
returns a new df with column names cleaned, old df does not change
see also ez.clcoldata
all upper to lower using regex (ignore.case=FALSE or TRUE does not matter)
ez.clcolnames(iris,pattern='([[:upper:]])', replacement = '\\L\\1', perl = TRUE, ignore.case=FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.