Lightweight dplyr::if_else with the virtues and vices that come from such an approach.
Attempts to replicate dplyr::if_else but written in base R for faster compile time.
originally hutils::if_else was faster than dplyr::if_else but since dplyr v 1.2.0
this is no longer the case,
nor will hutils::if_else work on lists or on factors.
Additional attributes may be dropped.
if_else(condition, true, false, missing = NULL)Where condition is TRUE, the corresponding value in true;
where condition is FALSE, the corresponding value in false.
Where condition is NA, then the corresponding value in na --
unless na is NULL (the default) in which case the value will be NA (with the same
type as true.)
Logical vector.
Where condition is TRUE/FALSE, use the correspondingtrue/no value.
They must have the same typeof as each other and be the same length as condition or length-one.
If condition is NA, use the corresponding na value. Liketrue andfalse, must
be of the same type and have the same length as condition, unless it has length one.
If the result is expected to be a factor then the conditions for type safety are strict and may be made stricter in future.