CollapsABEL (version 0.10.11)

changeByMap: Transform a vector by a mapping

Description

The mapping is represented by a data.frame: 1st column is the domain, 2st column is the range.

Usage

changeByMap(old_vector, mapping_dat, reverse = FALSE)

Arguments

old_vector
vector of any type.
mapping_dat
data.frame, first column must be the same type as the old_vector
reverse
logical. Reverse domain and range if set to TRUE

Value

The new vector (mapped from the old one).

Examples

Run this code
## Not run: 
# names_dat = data.frame(c("a", "b", "c"), c("d", "e", "f"), stringsAsFactors=FALSE)
# changeByMap(c("a", "a", "b"), names_dat) == c("d", "d", "e")
# x = changeByMap(c(NA, "a", "b"), names_dat)
# is.na(x[1])
# ## End(Not run)

Run the code above in your browser using DataLab