Recall & Review
beginner Click to reveal answer
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.
beginner Click to reveal answer
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.
beginner Click to reveal answer
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.
intermediate Click to reveal answer
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.
beginner Click to reveal answer
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.
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.
