Description Usage Arguments Value Examples
Replace multiple unique elements with multiple unique replacements.
1 | replace_values(vector, values, replacements, warn = TRUE)
|
vector |
Vector to make replacements in. |
values |
Values to be replaced (vector of same length as
|
replacements |
Values to replace matches with (vector of same length as
|
warn |
Logical indicating whether to issue a warning message if no element is replaced. |
Vector with elements in values replaced with the
corresponding elements from replacements.
Every element in values will be searched for in vector. If it is
found, it will be replaced in vector with the corresponding element of
replacements. That is, if the 3rd element of values is found
anywhere in vector, it will be replaced by the 3rd element of
replacements.
Note that factors will be releveled with the replacement values and levels no longer present in the factor may be lost.
1 2 3 4 5 6 7 8 | replace_values(
vector = c("WA", "WY", "OR", "NY", "NY", "WA", "FL", "OR"),
values = c("FL", "NY", "OR", "WA", "WY"),
replacements = c("Florida", "New York", "Oregon", "Washington", "Wyoming"))
replace_values(
vector = c("M", "F", "F", "M", "F", "M", "F", "M", "M", "M", "F", "F"),
values = c("F", "M"),
replacements = c("Female", "Male"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.