4.4 Comparisons
In R, comparisons will always return Logical data, i.e. either TRUE or False. We can use the following syntax to compare values:
• < and >: greater than, less than
• <= and >=: greater than or equal to, less than or equal to
For example:
## [1] TRUE
## [1] TRUE
• == checks if two values are equal. != checks if two values are different.
## [1] TRUE
Note that a single equals sign = can be used to assign values. However, a double equals sign == is used to compare values.
4.4.1 AND and OR
We can evaluate multiple conditions using the logical AND and OR operators.