Combines utils_clean_names() and zoo_name_set() to help clean, abbreviate, capitalize, and add a suffix or a prefix to the name of a zoo object.
Usage
zoo_name_clean(
x = NULL,
lowercase = FALSE,
separator = "_",
capitalize_first = FALSE,
capitalize_all = FALSE,
length = NULL,
suffix = NULL,
prefix = NULL
)Arguments
- x
(required, zoo object) Zoo time series to analyze. Default: NULL.
- lowercase
(optional, logical) If TRUE, all names are coerced to lowercase. Default: FALSE
- separator
(optional, character string) Separator when replacing spaces and dots. Also used to separate
suffixandprefixfrom 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) Suffix for the clean names. Default: NULL.
- prefix
(optional, character string) Prefix for the clean names. Default: NULL.
Examples
#simulate zoo time series
x <- zoo_simulate()
#get current name
zoo_name_get(x = x)
#> [1] "A"
#change name
x <- zoo_name_set(
x = x,
name = "My.New.name"
)
zoo_name_get(x = x)
#> [1] "My.New.name"
#clean name
x <- zoo_name_clean(
x = x,
lowercase = TRUE
)
zoo_name_get(x = x)
#> [1] "my_new_name"
