Any sufficiently advanced technology is equivalent to magic.

Top

Site Menu

Vectors

Assignment Operator, ' <- '

'<-' is used as the assignment operator in R. The assignment operator assigns the value on the right of the operator to the variable on the left of the operator.

For instance, "x <- 1" assigns the number 1 to the variable x. When you create a variable, the console will not return anything, even if it worked:
# no pec x <- 1

However, you will see in the Environment pane of RStudio (usually the top right), that a variable has appeared.
Screenshot of a software interface showing tabs labeled Environment, History, Connections, and Tutorial. The Global Environment panel is open, displaying a Values section where the variable “x” has a value of 1.
If you are only using R (not RStudio) or if you want to simply recall the value of your variable, just type the name of the variable and run the code and R will output that variable's value.
x <- 1 # The value 1 is stored in x. x

c() function, seq() function, and ' : ' notation