Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

vmap

Vectorized map from element to case by index or string value


Description

This function is a vectorized version of switch, that is, for each element of input vector, switch is evaluated and the results are combined.

Usage

vmap(EXPR, ..., SIMPLIFY = TRUE)

Arguments

EXPR

an expression evaluated to be character or numeric vector/list.

...

The list of alternatives for each switch.

SIMPLIFY

TRUE to simplify the resulted list to vector, matrix or array if possible.

See Also

Examples

x <- c("normal","normal","error","unknown","unknown")
vmap(x, normal = 0, error = -1, unknown = -2)

x <- c(1,1,2,1,2,2,1,1,2)
vmap(x, "type-A", "type-B")

formattable

Create 'Formattable' Data Structures

v0.2.1
MIT + file LICENSE
Authors
Kun Ren [aut, cre], Kenton Russell [aut]
Initial release
2021-01-05

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.