Replace the values in a vector
replace_values(x, from, to, must_have=TRUE)
Arguments
- x
vector
- from
values to be changed
- to
what values need to be changed to
- must_have
logical. Give an error if a value in from is not in x
Examples
v <- LETTERS[1:5]
replace_values(v, c("A", "B", "C"), c("first", "abc", "third"))
#> [1] "first" "abc" "third" "D" "E"