Learn R Programming

crtests (version 0.2.1)

replace_names: Replace strings in the names of an object

Description

Replaces strings matching the pattern in the names of the object by the replacement. If applicable, both row and column names could be replaced. This function is a simple wrapper to str_replace_all

Default method that replaces names(object)

Replaces row.names in the object, then dispatches to the default

Replace row.names and col.names in the object

Usage

replace_names(object, pattern, replacement, ...)
"replace_names"(object, pattern = "\\.", replacement = " ", ...)
"replace_names"(object, pattern = "\\.", replacement = " ", replace_rownames = TRUE, replace_colnames = TRUE, ...)
"replace_names"(object, pattern = "\\.", replacement = " ", replace_rownames = TRUE, replace_colnames = TRUE, ...)

Arguments

object
Object of which the names are to be changed
pattern
Pattern to look for, as defined by a POSIX regular expression
replacement
Replacement string
...
extra arguments to replace_names
replace_rownames
Logical. Should row names be replaced?
replace_colnames
Logical. Should column names be replaced?

Methods (by class)

  • default: Replace names of an object
  • data.frame: Replace names of a data.frame
  • matrix: Replace names in a matrix

See Also

str_replace_all