Essentially the same as dplyr::case_when but the variable is of class factor, ordered based on the order entered into the case_when statement
Arguments
- ...
as per dplyr::case_when, essentially all input is passed through to dplyr::case_when
A sequence of two-sided formulas. The left hand side (LHS) determines which values match this case. The right hand side (RHS) provides the replacement value. The LHS must evaluate to a logical vector. The RHS does not need to be logical, but all RHS must evaluate to the same type of vector.
Both LHS and RHS may have the same length of either 1 or n. The value of n must be consistent across all cases. The case of n == 0 is treated as a variant of n != 1.
NULL inputs are ignored.
Value
A vector of length 1 or n, of class factor, matching the length of the logical input or output vectors. Inconsistent lengths or types will generate an error.
Details
For a more thorough example, see the vignette.