if
expression or
an
if
-
else
expression is possible.
if(test) true.expr if(test) true.expr else false.expr e1 || e2 e1 && e2
if
construct in the language evaluates
test
.
If it is
TRUE
(i.e., if the first element of the result coerced to
mode
logical
is
TRUE
), then
true.expr
is evaluated and returned as the value of the whole expression.
Otherwise, the value of the expression is
false.expr
if present, or an
empty value otherwise.
TRUE
if both of its operands are
TRUE
(in the same sense
as
test
above). If the left operand is not
TRUE
, the right operand
is not evaluated.
TRUE
if one of its operands is
TRUE
(in the same sense
as
test
above). If the left operand is
TRUE
, the right operand
is not evaluated.
An
NA
value for the test causes an error.
A zero length logical vector causes an error if passed as the left operand for
||
or passed as either operand for
&&
.
The && and || operators are members of the
Ops
group of generic
functions.
if(mode(x)!="character" && min(x)>0) log(x) # log(x) is an error if mode(x) is "character" if(is.na(okay)) z <- z+1 else if(okay) {y <- rnorm(1); x <- runif(1)}