Replace names using a pattern. Calls stringr::str_replace_all().

replace_names(x, pattern, replacement, ...)

Arguments

x

a named object

pattern

regex pattern

replacement

replacement

...

Arguments passed on to stringr::str_replace_all

string

Input vector. Either a character vector, or something coercible to one.

Value

x with replaced names.

See also

Examples

fruits <- c(one = "one apple", two = "two pears", three = "three bananas") replace_names(fruits, '^([a-z])', 'fruit_\\1')
#> Error in replace_names(fruits, "^([a-z])", "fruit_\\1"): could not find function "replace_names"
replace_names(fruits, '^([a-z])', toupper)
#> Error in replace_names(fruits, "^([a-z])", toupper): could not find function "replace_names"