Learn R Programming

mudata (version 0.1.1)

rename.values: Replace/rename values in a vector

Description

This function replaces character values with new character values, which is useful when performing rename operations when values are held in character vectors.

Usage

rename.values(x, ..., defaultValue = x, warn_missing = TRUE)

Arguments

x

Vector of values to replace

...

Key/value pairs in the form oldvalue="newvalue"

defaultValue

A vector of values to use as the default should the value not be found in ...

warn_missing

Print a message if any old names are not actually present in x

Value

A vector with values replaced

Examples

Run this code
# NOT RUN {
x <- c("fish", "fish", "fish", "whistle")
rename.values(x, fish="newfish")
rename.values(x, whistle="newwhistle")
rename.values(x, fish="newfish", defaultValue="not a fish")

# }

Run the code above in your browser using DataLab