elif: elif Generate vectorized if-else logic with pleasing syntax

Description Usage Arguments Value Examples

Description

elif Generate vectorized if-else logic with pleasing syntax

Usage

1
elif(..., env = parent.frame())

Arguments

...

Expressions separated by commas mapping predicates to values. The -> operator reminiscent to pattern matching in other languages. The last expression must be a default value or an error will be thrown.

env

Where the resultant expression should be evaluated. Defaults to the parent.frame().

Value

the result of the evaulated ifelse expression evaulated in env.

Examples

1
2
3
4
5
6
7
8
## Not run: 
res <- with(mtcars, elif(
 cyl == 4 -> "a",
 cyl == 6 -> "b",
 cyl == 8 -> "c", "d"))
table(res, mtcars$cyl)

## End(Not run)

Zelazny7/elif documentation built on May 25, 2019, 9:23 a.m.