| case | R Documentation |
case and val_match are cheaper alternatives to dplyr::case_when and
dplyr::case_match respectively.
case(..., .default = NULL)
val_match(.x, ..., .default = NULL)
... |
Logical expressions or scalar values in the case of |
.default |
Catch-all value or vector. |
.x |
Vector used to switch values. |
val_match() is a very efficient special case of the
case() function when all lhs expressions are scalars,
i.e. length-1 vectors. RHS expressions can be vectors the
same length as .x.
The below 2 expressions are equivalent.
val_match( x, 1 ~ "one", 2 ~ "two", .default = "Unknown" ) case( x == 1 ~ "one", x == 2 ~ "two", .default = "Unknown" )
A vector the same length as .x or same length as the first condition in the
case of case, unless the condition length is smaller than the
rhs, in which case the length of the rhs is used.
if_else_
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.