Learn R Programming

broman (version 0.68-2)

switchv: Vectorized version of switch

Description

Vectorized version of switch: just loops over input and calls switch.

Usage

switchv(EXPR, ...)

Arguments

EXPR

An expression evaluating to a vector of numbers of strings

...

List of alternatives

Value

Vector of returned values.

Examples

Run this code
# NOT RUN {
switchv(c("horse", "fish", "cat", "bug"),
        horse="fast",
        cat="cute",
        "what?")

# }

Run the code above in your browser using DataLab