0
0
R Programmingprogramming~5 mins

Comparison 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 checks if two values are equal and returns TRUE if they are, otherwise FALSE.
Click to reveal answer
beginner
How do you check if one value is greater than another in R?
Use the > operator to check if the left value is greater than the right value. It returns TRUE or FALSE.
Click to reveal answer
beginner
What is the difference between == and != in R?
== checks if two values are equal, while != checks if two values are NOT equal.
Click to reveal answer
beginner
What do the operators <= and >= mean in R?
<= means 'less than or equal to' and >= means 'greater than or equal to'. They compare two values and return TRUE or FALSE.
Click to reveal answer
intermediate
How does R handle comparison of vectors with comparison operators?
R compares vectors element by element and returns a logical vector of TRUE or FALSE for each comparison.
Click to reveal answer
What will 5 == 5 return in R?
ATRUE
BFALSE
C5
DError
Which operator checks if two values are NOT equal in R?
A<=
B==
C>=
D!=
What does 3 >= 4 return?
AFALSE
BTRUE
C3
D4
How does R compare vectors with < operator?
AThrows an error
BCompares only first elements
CElement-wise comparison returning logical vector
DReturns a single TRUE or FALSE
What is the result of c(1,2,3) == 2 in R?
ATRUE TRUE TRUE
BFALSE TRUE FALSE
CTRUE FALSE TRUE
DFALSE FALSE FALSE
Explain how comparison operators work in R and give examples of at least three different operators.
Think about how you check if two things are equal or one is bigger than the other.
You got /4 concepts.
    Describe how R handles comparison when using vectors instead of single values.
    Imagine comparing two lists of numbers one by one.
    You got /3 concepts.