replaceEntries {easy.utils}R Documentation

Replace entries according to a mapping list

Description

Replace entries according to a mapping list

Usage

replaceEntries(x, map, ...)

## S4 method for signature 'vector,list'
replaceEntries(x, map, ...)

Arguments

x

An R vector

map

A named list representing one-to-one or one-to-many mappings. Normally, each name represents a new value, and each element contain the old value(s) to be replaced.

...

Arguments passed to other methods.

Value

A updated x

Examples

set.seed(1234)
fact <- factor(c("A", "A", "B", "A", "B", "C", "D", "E", "D"))
map <- list("a" = c("B", "e")) ## Turn all "B" and "E" into "a"
replaceEntries(fact, map)


[Package easy.utils version 0.0.4 Index]