0
0
R Programmingprogramming~5 mins

Logical operators (&, |, !, &&, ||) in R Programming - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the & operator do in R?
The & operator performs element-wise logical AND between two logical vectors. It compares each element and returns TRUE only if both elements are TRUE.
Click to reveal answer
intermediate
Explain the difference between & and && in R.
& works element-wise on vectors, comparing each element. && only checks the first element of each vector and returns a single TRUE or FALSE.
Click to reveal answer
beginner
What does the ! operator do in R?
The ! operator negates a logical value or vector. It changes TRUE to FALSE and FALSE to TRUE for each element.
Click to reveal answer
beginner
How does the | operator work in R?
The | operator performs element-wise logical OR between two logical vectors. It returns TRUE if at least one element in the pair is TRUE.
Click to reveal answer
intermediate
What is the difference between | and || in R?
| works element-wise on vectors, comparing each element. || only checks the first element of each vector and returns a single TRUE or FALSE.
Click to reveal answer
Which operator in R performs element-wise logical AND?
A|
B&
C&&
D||
What does the ! operator do in R?
ALogical NOT (negation)
BLogical AND
CLogical OR
DChecks first element only
Which operator checks only the first element of logical vectors in R?
A&&
B&
C|
D!
What is the result of TRUE | FALSE in R?
AFALSE
BError
CNA
DTRUE
Which operator performs element-wise logical OR in R?
A||
B&
C|
D&&
Describe the differences between & and && operators in R.
Think about how these operators behave with vectors.
You got /3 concepts.
    Explain how the ! operator works and give an example.
    Consider what happens when you apply it to a logical vector.
    You got /4 concepts.