switchv: A vectorised version of switch

Description Usage Arguments Value Examples

Description

A vectorised version of switch

Usage

1
switchv(EXPR, type = character(1), ...)

Arguments

EXPR

An expression evaluating to a number or a character string.

type

switchv uses vapply so this is the type returned from each iteration. Same as FUN.VALUE argument in vapply.

...

the list of alternatives.

Value

Same as switch but used on a vector.

Examples

1
2
3
4
myvec <- c('apple', 'cabbage')
switchv(myvec, 
        apple = 'fruit',
        cabbage = 'veggetable')

LyzandeR/D2DF documentation built on May 8, 2019, 3:16 p.m.