Cleans names of a dataframe while retaining old names as labels
clean_names_with_labels( df, except = NULL, .fun = getOption("crosstable_clean_names_fun") )
df
: a data.frameexcept
: <tidy-select
> columns that should not be renamed..fun
: the function used to clean the names. Default function is limited; if the cleaning is not good enough you could use janitor::make_clean_names()A dataframe with clean names and label attributes
#options(crosstable_clean_names_fun=janitor::make_clean_names) x = data.frame("name with space"=1, TwoWords=1, "total $ (2009)"=1, àccénts=1, check.names=FALSE) cleaned = clean_names_with_labels(x, except=TwoWords) cleaned %>% names() cleaned %>% get_label()
Dan Chaltiel
Useful links