Table of Contents
Relational Operators in R Programming Language: Explanation and Usage
Relational Operators
Following table shows the relational operators supported by R language. Each element of the first vector is compared with the corresponding element of the second vector. The result of comparison is a Boolean value.
| Operator | Description | Example |
|---|---|---|
| > | Checks if each element of the first vector is greater than the corresponding element of the second vector. |
it produces the following result −
|
| < | Checks if each element of the first vector is less than the corresponding element of the second vector. |
it produces the following result −
|
| == | Checks if each element of the first vector is equal to the corresponding element of the second vector. |
it produces the following result −
|
| <= | Checks if each element of the first vector is less than or equal to the corresponding element of the second vector. |
it produces the following result −
|
| >= | Checks if each element of the first vector is greater than or equal to the corresponding element of the second vector. |
it produces the following result −
|
| != | Checks if each element of the first vector is unequal to the corresponding element of the second vector. |
it produces the following result −
|
More Exampels
> x <- 5
> y <- 16
> x<y
[1] TRUE
> x>y
[1] FALSE
> x<=5
[1] TRUE
> y>=20
[1] FALSE
> y == 16
[1] TRUE
> x != 5
[1] FALSE