Skip to contents

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 suffix and prefix from 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.

Value

zoo time series

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"
)
#> distantia::zoo_name_set(): renaming zoo time series from 'A' to 'My.New.name'.

zoo_name_get(x = x)
#> [1] "My.New.name"

#clean name
x <- zoo_name_clean(
  x = x,
  lowercase = TRUE
)
#> distantia::zoo_name_set(): renaming zoo time series from 'My.New.name' to 'my_new_name'.

zoo_name_get(x = x)
#> [1] "my_new_name"