Course Content

# R Introduction: Part I

R Introduction: Part I

## Logical Type

We're now turning our attention to logical data types.

Logical data types can only hold two values: `TRUE` or `T`, and `FALSE` or `F`. It's important to note that these values are case-sensitive; thus, `false` is not recognized as a logical type.

Logical types are primarily used for evaluating conditions. For instance, if you evaluate `2 > 1`, it will return `TRUE` because `2` is indeed greater than `1`. This principle will be highly relevant in later chapters.

Numbers and strings can also be converted to logical types. Any number except `0` will be converted to `TRUE` (`0` converts to `FALSE`), and the strings `'F'`, `'false'`, `'False'`, and `'FALSE'` will convert to the logical `FALSE`. The same principle applies for logical `TRUE`.

When converting logical values to numbers, `FALSE` becomes `0`, and `TRUE` becomes `1`.

1. Assign the result of the expression `19*54 > 76*13` to the variable `logic`.
2. Display the value of the `logic` variable.
3. Display the data type of the `logic` variable.
4. Convert the `logic` variable to an `integer` and display the result.
Avoid using the `print()` function here.