Recall & Review
beginner
What values does the logical (boolean) type represent in R?
The logical type in R represents two main values: TRUE and FALSE. It is used to store truth values.
Click to reveal answer
beginner
How do you create a logical vector with TRUE and FALSE values in R?
You can create a logical vector using the c() function, for example:
c(TRUE, FALSE, TRUE).Click to reveal answer
beginner
What is the result of the expression
5 > 3 in R?The expression
5 > 3 evaluates to TRUE because 5 is greater than 3.Click to reveal answer
intermediate
How does R treat the logical values TRUE and FALSE when used in arithmetic operations?
In arithmetic, TRUE is treated as 1 and FALSE as 0. For example,
TRUE + TRUE equals 2.Click to reveal answer
intermediate
What function can you use to check if a value is logical in R?
You can use the
is.logical() function to check if a value or vector is of logical type.Click to reveal answer
Which of the following is a logical value in R?
✗ Incorrect
TRUE is a logical value. "TRUE" is a string, and 1 and 0 are numeric.
What does the expression
is.logical(c(TRUE, FALSE, TRUE)) return?✗ Incorrect
The vector contains logical values, so is.logical() returns TRUE.
What is the output of
TRUE + FALSE in R?✗ Incorrect
TRUE is treated as 1 and FALSE as 0, so the sum is 1.
Which operator is used to compare two values and return a logical result?
✗ Incorrect
The > operator compares values and returns TRUE or FALSE.
What is the class of the value
FALSE in R?✗ Incorrect
FALSE is of class logical.
Explain what the logical (boolean) type is in R and give examples of how it is used.
Think about how R stores yes/no or true/false answers.
You got /4 concepts.
Describe how logical values behave when used in arithmetic operations in R.
Consider how R treats TRUE and FALSE as numbers.
You got /4 concepts.