keymapping: Map a variable

Description Usage Arguments Value Examples

View source: R/utils.R

Description

Sometimes we need to map one vector into another. For inhouse data it can be useful when defining categories for carteras modelo, id's or emisoras. This function maps origin -> target for every value of x.

Usage

1
keymapping(x, origin, target, replace_missing = FALSE)

Arguments

x

The vector that will be transformed; x must have values in origin.

origin

A vector

target

A vector of the same length as origin

replace_missing

Indicates whether the values of x that are not found origin should be changed. If replace_missing is given a value other than FALSE then this value will be used as replacement for the values of x not found in origin.

Value

A transformed vector

Examples

1
2
keymapping(1:6, c(2,3), c(-1, -2))
keymapping(1:6, c(2,3), c(-1, -2), replace_missing = NA)

optimist/inhouse documentation built on May 24, 2019, 3:56 p.m.