0
0
R Programmingprogramming~10 mins

Logical (boolean) type in R Programming - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a logical variable with value TRUE.

R Programming
flag <- [1]
Drag options to blanks, or click blank then click option'
Atrue
BTRUE
C"TRUE"
D1
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.
2fill in blank
medium

Complete 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'
A>
B<
C==
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' which means less than.
Using '==' which checks equality, not greater than.
3fill in blank
hard

Fix 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'
A0
BFalse
C"FALSE"
DFALSE
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'False' which is not recognized in R.
Using quotes around FALSE, making it a string.
4fill in blank
hard

Fill 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'
ATRUE
BFALSE
C"TRUE"
D"FALSE"
Attempts:
3 left
💡 Hint
Common Mistakes
Using quoted strings instead of logical values.
Using lowercase true or false.
5fill in blank
hard

Fill 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'
ATRUE
BFALSE
C2 == 2
D"TRUE"
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around TRUE or FALSE.
Using incorrect comparison operators.