Assignment Operators
In this page:
Assignment Operators
R conventionally uses <- for assignment, though = also works in most contexts. <- is preferred by style guides because it's unambiguous everywhere, including inside function calls where = has a different meaning (naming an argument). The right-pointing -> is also valid and assigns from left to right.
Warning: Inside a function call, f(x = 1) sets a named argument, not a variable assignment -- use <- when you actually mean assignment.
Example: Assignment Operators
x <- 10
y = 20
30 -> z
cat(x, y, z, "\n")
Login to try C/C++/Java/PHP code in the editor
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: