Читать книгу The Big R-Book - Philippe J. S. De Brouwer - Страница 122
4.4.4 Assignment Operators
ОглавлениеR has multiple ways to express an assignment. While it is possible to mix and match, we prefer to choose just one and stick with it. We will use <-
.
operator – assignment
and
or
# left assignment x <- 3 x = 3 x<<- 3 # right assignment 3 -> x 3 ->> x #chained assignment x <- y <- 4
not
The <<-
or ->>
operators change a variable in the actual environment and the environment above the actual one. Environments will be discussed in Section 5.1 “Environments in R” on page 110. Till now we have always been working in the command prompt. This is the root-environment. A function will create a new (subordinated) environment and might for example use a new variable. When the function stops running that environment stops to exist and the variable exists no longer.3
assignment – left
assignment – right
assignment – chained