Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a logical variable with value TRUE.
R Programming
flag <- [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'true' which is not recognized in R.
Using quotes around TRUE, which makes it a string, not logical.
✗ Incorrect
In R, logical TRUE is written as TRUE (all uppercase, no quotes).
2fill in blank
mediumComplete the code to check if 5 is greater than 3 and store the result in a logical variable.
R Programming
result <- 5 [1] 3
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' which means less than.
Using '==' which checks equality, not greater than.
✗ Incorrect
The expression 5 > 3 returns TRUE because 5 is greater than 3.
3fill in blank
hardFix the error in the code to correctly assign a logical FALSE value.
R Programming
is_valid <- [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'False' which is not recognized in R.
Using quotes around FALSE, making it a string.
✗ Incorrect
Logical FALSE in R is written as FALSE (all uppercase, no quotes).
4fill in blank
hardFill both blanks to create a logical vector with TRUE and FALSE values.
R Programming
vec <- c([1], [2])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using quoted strings instead of logical values.
Using lowercase true or false.
✗ Incorrect
Logical vectors use TRUE and FALSE without quotes.
5fill in blank
hardFill all three blanks to create a logical vector with TRUE, FALSE, and the result of 2 == 2.
R Programming
vec <- c([1], [2], [3])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around TRUE or FALSE.
Using incorrect comparison operators.
✗ Incorrect
The vector contains logical TRUE, logical FALSE, and the result of the comparison 2 == 2 which is TRUE.