R Programming language - R Boolean Expression
In R programming language, a Boolean expression is an expression that evaluates to either TRUE or FALSE. It is used to test conditions in control structures such as if-else statements, while loops, and for loops.
The following operators can be used to construct Boolean expressions in R:
Comparison operators:
==
for equal to!=
for not equal to<
for less than>
for greater than<=
for less than or equal to>=
for greater than or equal toLogical operators:
&
for logical AND|
for logical OR!
for logical NOTSpecial operators:
isTRUE()
to test if an expression is TRUEisFALSE()
to test if an expression is FALSEis.na()
to test if an expression is NA (missing value)identical()
to test if two objects are identical
Examples of Boolean expressions in R:
regi:ot refiftidea.comx <- 5 y <- 10 x == y # FALSE x != y # TRUE x < y # TRUE x > y # FALSE x <= y # TRUE x >= y # FALSE a <- TRUE b <- FALSE a & b # FALSE a | b # TRUE !a # FALSE isTRUE(a) # TRUE is.na(x) # FALSE identical(x, y) # FALSE