if_else | R Documentation |
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.
hutils::if_else
should be faster than dplyr::if_else
... when it works,
but will not work on lists or on factors.
Additional attributes may be dropped.
if_else(condition, true, false, missing = NULL)
condition |
Logical vector. |
true, false |
Where condition is |
missing |
If condition is |
If the result is expected to be a factor then the conditions for type safety are strict and may be made stricter in future.
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
.)
Original code but obviously heavily inspired by https://CRAN.R-project.org/package=dplyr.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.