Course Content
R Introduction: Part I
1. Basic Syntax and Operations
R Introduction: Part I
Logical Type
Good job! Let's move on to the study of the following data type - logical.
Values of this data type can only take two values: TRUE
or T
and FALSE
or F
. Note that the wording is case-sensitive, i.e., false
will not be considered a logical type.
Primarily, the logical type is used while checking certain statements. For example, if you compile something like 2 > 1
, you will receive TRUE
since 2
is greater than 1
. This fact will be widely used a few chapters later.
You can also convert numbers and text into logical types. All the numbers but 0
will be converted into TRUE
(otherwise FALSE
for 0
), and strings 'F'
, 'false'
, 'False'
, and 'FALSE'
into logical FALSE
. The same for logical TRUE
.
Converting logical values into numerical will result in 0
for FALSE
, and 1
for TRUE
.
Task
- Assign the result of statement
19*54 > 76*13
tologic
variable. - Output the value of the
logic
variable. - Output the type of the
logic
variable. - Convert the value of the
logic
variable intointeger
, and output this value. Do not useprint()
function there.
Everything was clear?