A vectorised if or else function. It checks that the true or false (or the optional missing)
arguments have the same type. However it accepts a generic NA. Built upon
dplyr's [if_else()] function. The only difference is that the user do not have to specify
the type of NA. if_else_ is faster than base [ifelse()] and a tad slower than
dplyr's [if_else()]. Attributes are taken from either true or false because one
generic NA.
Usage
if_else_(condition, true, false, missing = NULL)
Value
a vector
Arguments
condition
logical vector
true
value to replace if condition is true. Must be same length as condition or 1.
false
value to replace if condition is false. Must be same length as condition or 1.
missing
optional. a replacement if condition returns NA. Must be same length as condition or 1.
Details
If the returning vector have attributes (e.g. for factors) it returns the attributes
for the first non-generic NA in the order true, false and then missing.