casewhen

Vectorized case-when

Evaluates a series of condition ~ value formulas sequentially. Returns the value corresponding to the first true condition for each element.

Parameters

Returns

A vector of the matched values.

Examples

casewhen(
x > 0 ~ "Positive",
x < 0 ~ "Negative",
.default = "Zero"
)