Conditional transformations (1)
Aim: generate a vector where each element is determined by the value of one or multiple conditions (~ comparisons).
- one condition: use
if_else()
if_else(condition, true, false, missing = NULL)
- multiple (hierarchical) conditions: use
case_when(..., .default = NULL)
.- the first condition that is
TRUE
for an element determines the outcome for that element.
- the first condition that is