mapValues | R Documentation |
Replace values in atomic vectors
mapValues( x, from, to, regex = FALSE, ignore.case = FALSE, perl = FALSE, fixed = FALSE )
x |
[ |
from |
[ |
to |
[ |
regex |
[ |
ignore.case |
[ |
perl |
[ |
fixed |
[ |
Replaces values specified in from
with values in to
.
Regular expression matching can be enabled which calls gsub
iteratively
on x
to replace all patterns in from
with replacements in to
.
[atomic
].
# replace integers x = 1:5 mapValues(x, c(2, 3), c(99, 100)) # replace factor levels using regex matching x = factor(c("aab", "aba", "baa")) mapValues(x, "a.a", "zzz", regex = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.