powered by
data.table::fcase()
This 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.
default
case.(..., default = NA, ptype = NULL, size = NULL)
Sequence of condition/value designations
Default value. Set to NA by default.
Optional ptype to specify the output type.
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))
Run the code above in your browser using DataLab