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:

  1. Comparison operators:

  2. == for equal to

  3. != for not equal to

  4. < for less than

  5. > for greater than

  6. <= for less than or equal to

  7. >= for greater than or equal to

  8. Logical operators:

  9. & for logical AND

  10. | for logical OR

  11. ! for logical NOT

  12. Special operators:

  13. isTRUE() to test if an expression is TRUE

  14. isFALSE() to test if an expression is FALSE

  15. is.na() to test if an expression is NA (missing value)

  16. identical() to test if two objects are identical

Examples of Boolean expressions in R:

re‮gi:ot ref‬iftidea.com
x <- 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