assignOps {base} | R Documentation

## Assignment Operators

### Description

Assign a value to a name.

### Usage

    x <- value
    x <<- value
    value -> x
    value ->> x

    x = value

### Arguments

`x` | a variable name (possibly quoted).
`value` | a value to be assigned to `x`.

### 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 `->>` cause a search to made through the environment for an existing definition of the variable being assigned. If such a variable is found then its value is redefined, otherwise assignment takes place globally. 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]]`). The name does not need to be quoted, though it can be.

The leftwards forms of assignment `<- = <<-` group right to left, the other from left to right.

### Value

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

### References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.

Chamber, J. M. (1998) Programming with Data. A Guide to the S Language. Springer (for `=`).

### See Also

`assign`, `environment`.

[Package base version 2.3.1 Index]