case | R Documentation |
data.table::fcase()
with vectorized defaultThis function allows you to use multiple if/else statements in one call.
It is called like data.table::fcase()
, but allows the user to use
a vector as the default
argument.
case(..., default = NA, ptype = NULL, size = NULL)
... |
Sequence of condition/value designations |
default |
Default value. Set to NA by default. |
ptype |
Optional ptype to specify the output type. |
size |
Optional size to specify the output size. |
df <- tidytable(x = 1:10)
df %>%
mutate(case_x = case(x < 5, 1,
x < 7, 2,
default = 3))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.