x <- value
x <<- value
value -> x
value ->> x
x = value
x
. 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 <<-< code=""> and
->>
are normally only used in
functions, and cause a search to 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 useful in conjunction with the scoping rules of
R. See The R Language Definition manual for further
details and examples.<-<>
In all the assignment operator expressions, x
can be a name
or an expression defining a part of an object to be replaced (e.g.,
z[[1]]
). A syntactic name does not need to be quoted,
though it can be (preferably by backticks).
The leftwards forms of assignment <- = <<-< code=""> group right to left,
the other from left to right.
<-<>
Chamber, J. M. (1998)
Programming with Data. A Guide to the S Language.
Springer (for =
).
assign
, for subassignment such
as x[i] <- v
, [<-
;
environment
.