ID EN
Environment & Scope

assignOps

R Base 3.6.2

Assign a value to a name.

Syntax

R
<code>x &lt;- value</code>
<code>x <&lt;- value<="" code="">
<code>value -> x</code>
<code>value ->> x</code><p></p><p><code>x = value</code></p></&lt;-></code>

Arguments

Parameter Description
x a variable name (possibly quoted).
value a value to be assigned to x.

Return Value

value. Thus one can use a <- b <- c <- 6.

Details

There are three different assignment operators: two of them have leftwards and rightwards forms. The operators <- and = assign into the environment in which they are evaluated. The operator <- can be used anywhere, whereas the operator = is only allowed at the top level (e.g., in the complete expression typed at the command prompt) or as one of the subexpressions in a braced list of expressions. The operators <<- and ->> are normally only used in functions, and cause a search to be made through parent environments for an existing definition of the variable being assigned. If such a variable is found (and its binding is not locked) then its value is redefined, otherwise assignment takes place in the global environment. Note that their semantics differ from that in the S language, but are us

See Also

assign (and its inverse get) for “subassignment” such as x[i] <- v see [<-; further environment.