| IfElse {resample} | R Documentation |
Conditional Data Selection
Description
This is equivalent to {if(test) yes else no}.
The advantages of using this function are better formatting, and a more
natural syntax when the result is being assigned; see examples below.
With 5 arguments, this is equivalent to
{if(test1) yes else if(test2) u else v}
(where arguments are given by name, not position).
Usage
IfElse(test, yes, no, ...)
Arguments
test |
logical value; if |
yes |
any object; this is returned if |
no |
normally any object; this is returned if |
... |
there should be 3, 5, 7, etc. arguments to this function; arguments 1, 3, 5, etc. should be logical values; the other arguments (even numbered, and last) are objects that may be returned. |
Details
test should be a scalar logical, and only one of yes or
no is evaluated, depending on whether test = TRUE or
test = FALSE, and yes and no may be any objects.
In contrast, for
ifelse, test is normally a vector, both yes and no
are evaluated, even if
not used, and yes and no are vectors the same length as
test.
Value
with three arguments, one of yes or no.
With k arguments, one of arguments 2, 4, ..., k-1, k.
Author(s)
Tim Hesterberg timhesterberg@gmail.com,
https://www.timhesterberg.net/bootstrap-and-resampling
See Also
Examples
IfElse(TRUE, "cat", "dog")
IfElse(FALSE, "one", TRUE, "two", "three")
IfElse(FALSE, "one", FALSE, "two", "three")