Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

map_values

Replace Elements of Vectors with New Values


Description

Replaces all values in x which match old with values in new. Values are matched with base::match().

Usage

map_values(x, old, new)

Arguments

x

(vector()).

old

(vector())
Vector with values to replace.

new

(vector())
Values to replace with. Will be forced to the same length as old with base::rep_len().

Value

(vector()) of the same length as x.

Examples

x = letters[1:5]

# replace all "b" with "_b_", and all "c" with "_c_"
old = c("b", "c")
new = c("_b_", "_c_")
map_values(x, old, new)

mlr3misc

Helper Functions for 'mlr3'

v0.10.0
LGPL-3
Authors
Michel Lang [cre, aut] (<https://orcid.org/0000-0001-9754-0393>), Patrick Schratz [aut] (<https://orcid.org/0000-0003-0748-6624>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.