Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to perform element-wise logical AND on vectors a and b.
R Programming
result <- a [1] b Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '&&' instead of '&' causes only the first element to be compared.
Using '|' or '||' instead of AND operators.
✗ Incorrect
In R, & performs element-wise logical AND between vectors.
2fill in blank
mediumComplete the code to perform element-wise logical OR on vectors x and y.
R Programming
result <- x [1] y Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '&&' or '&' instead of OR operators.
Using '!' which is logical NOT.
✗ Incorrect
The | operator performs element-wise logical OR in R.
3fill in blank
hardFix the error in the code to negate the logical vector v.
R Programming
negated <- [1]v Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '&&' or '&' which are AND operators.
Using '|' which is OR operator.
✗ Incorrect
The ! operator negates each element of a logical vector in R.
4fill in blank
hardFill both blanks to create a vector of TRUE where elements of a are TRUE and elements of b are FALSE.
R Programming
result <- a [1] [2]b
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '|' instead of '&' for AND operation.
Not negating b before AND.
✗ Incorrect
Use & for element-wise AND and ! to negate vector b.
5fill in blank
hardFill all three blanks to create a vector where elements are TRUE if a is TRUE or b is FALSE, but not both.
R Programming
result <- (a [1] ([2]b)) [3] (a [1] b)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using AND instead of OR.
Not using XOR to exclude both TRUE.
✗ Incorrect
This expression uses OR |, NOT !, and XOR ^ to get TRUE where only one condition is TRUE.