Switch | R Documentation |
Present since hutils 1.2.0
. Vectorized version of switch
. Used to avoid or make clearer the result of
if_else(Expr == , ..1, if_else(Expr == , ..2, ...))
Switch(Expr, ..., DEFAULT, IF_NA = NULL, MUST_MATCH = FALSE)
Expr |
A character vector. |
... |
As in |
DEFAULT |
A mandatory default value should any name of |
IF_NA |
Optional value to replace missing ( |
MUST_MATCH |
(logical, default: |
For every element of ...
whose name matches an element of Expr
,
that element's value.
Switch(c("a", "b", "c", "a"), "a" = 1, "b" = 2, "c" = 3, "4" = 4, DEFAULT = 0)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.