Clean Character Vector of Names
Clean and format character vectors for use as column names or variable names.
utils_clean_names( x = NULL, lowercase = FALSE, separator = "_", capitalize_first = FALSE, capitalize_all = FALSE, length = NULL, suffix = NULL, prefix = NULL )
x
: (required, character vector) Names to be cleaned. Default: NULLlowercase
: (optional, logical) If TRUE, all names are coerced to lowercase. Default: FALSEseparator
: (optional, character string) Separator when replacing spaces and dots and appending suffix
and prefix
to the main word. Default: "_".capitalize_first
: (optional, logical) Indicates whether to capitalize the first letter of each name Default: FALSE.capitalize_all
: (optional, logical) Indicates whether to capitalize all letters of each name Default: FALSE.length
: (optional, integer) Minimum length of abbreviated names. Names are abbreviated via abbreviate()
. Default: NULL.suffix
: (optional, character string) String to append to the cleaned names. Default: NULL.prefix
: (optional, character string) String to prepend to the cleaned names. Default: NULL.character vector
The cleanup operations are applied in the following order:
base::make.names()
.separator
.length
is provided, base::abbreviate()
is used to abbreviate the new column names.suffix
is provided, it is added at the end of the column name using the separator.prefix
is provided, it is added at the beginning of the column name using the separator.capitalize_first = TRUE
, the first letter is capitalized.capitalize_all = TRUE
, all letters are capitalized.x <- c( "GerMany", "spain", "SWEDEN" ) #abbreviate names #--------------------------- #abbreviate to 4 characters utils_clean_names( x = x, capitalize_all = TRUE, length = 4 ) #suffix and prefix #--------------------------- utils_clean_names( x = x, capitalize_first = TRUE, separator = "_", prefix = "my_prefix", suffix = "my_suffix" )
Other internal: utils_boxplot_common()
, utils_check_args_distantia()
, utils_check_args_matrix()
, utils_check_args_momentum()
, utils_check_args_path()
, utils_check_args_tsl()
, utils_check_args_zoo()
, utils_check_distance_args()
, utils_check_list_class()
, utils_digits()
, utils_distantia_df_split()
, utils_prepare_df()
, utils_prepare_matrix()
, utils_prepare_matrix_list()
, utils_prepare_time()
, utils_prepare_vector_list()
, utils_prepare_zoo_list()
, utils_tsl_pairs()