Recall & Review
beginner
What does the <- operator do in R?
The <- operator assigns a value to a variable in R. It stores the value on the right into the variable on the left.
Click to reveal answer
beginner
How is the = operator used in R for variable assignment?
The = operator can also assign values to variables in R, similar to <-, but <- is preferred for clarity in scripts.
Click to reveal answer
beginner
Which operator is preferred for assignment in R scripts: <- or =?
The <- operator is preferred for assignment in R scripts because it clearly shows assignment and avoids confusion with function arguments.
Click to reveal answer
intermediate
Can you use both <- and = interchangeably for assignment in R?
Yes, both <- and = can assign values to variables, but <- is recommended for assignments and = is often used for function arguments.
Click to reveal answer
beginner
What happens if you write x <- 5 and then x = 10 in R?
The variable x first gets the value 5, then it is updated to 10. Both assignments change the value stored in x.
Click to reveal answer
Which operator is traditionally used for variable assignment in R?
✗ Incorrect
The <- operator is the traditional and preferred way to assign values to variables in R.
What does the = operator do in R when used outside function calls?
✗ Incorrect
Outside function calls, = assigns values to variables, similar to <-.
Which of these is NOT a correct way to assign 10 to variable x in R?
✗ Incorrect
x == 10 checks if x equals 10; it does not assign a value.
If you write x <- 5 and then x = 7, what is the value of x?
✗ Incorrect
The second assignment updates x to 7.
Why is <- preferred over = for assignment in R scripts?
✗ Incorrect
Using <- makes it clear you are assigning a value, not passing an argument.
Explain how to assign values to variables in R using both <- and = operators.
Think about how you store a value in a box labeled with a name.
You got /4 concepts.
Describe why <- is preferred over = for variable assignment in R scripts.
Consider how to make your code easier to read and understand.
You got /4 concepts.