changeByMap: Transform a vector by a mapping

Description Usage Arguments Value Author(s) Examples

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)

Example output

Loading required package: rJava
   a    a    b 
TRUE TRUE TRUE 
<NA> 
TRUE 

CollapsABEL documentation built on May 1, 2019, 7:28 p.m.