changeByMap: Transform a vector by a mapping

Description Usage Arguments Value Author(s) Examples

View source: R/0_glm2.R

Description

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

Usage

1
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).

Author(s)

Kaiyin Zhong, Fan Liu

Examples

1
2
3
4
5
6
7
## 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)

CollapsABEL documentation built on May 29, 2017, 9:43 a.m.