The third type of data in R is logical. It is generated mostly by conditions ( e.g.
2 > 1, or "two is greater than one"). There are only two logical values in R:
TRUE (when a condition is met) and
FALSE (when it's not).
The logical operators that generate these conditions are shown in the table below:
||Less than or equal to
||Greater than or equal to
||NOT equal to
OR operators can be used to join conditions. For example, say you wanted to find ages that were greater than 18 and less than or equal to 100. You'd write:
( age > 18 ) & ( age <= 100 )
This will return
TRUE only when the number variable age is greater than 18 AND equal to or less than 100.
FALSE are reserved for logical values. This means you cannot use "true" or "false" as variable names or indeed as any kind of object name.