Читать книгу The Big R-Book - Philippe J. S. De Brouwer - Страница 46
Assignment
ОглавлениеAssignment can be made left or right:
assignment
x.1 <- 5 x.1 + 3 -> .x print(.x) ## [1] 8
R-programmers will use the arrow sign <-
most often, however, R allows left assignment with the =
sign.
x.3 = 3.14 x.3 ## [1] 3.14
There are also occasions that we must use the =
operator. For example, when assigning values to named inputs for functions.
v1 <- c(1,2,3,NA) mean(v1, na.rm = TRUE) ## [1] 2
There are more nuances and therefore, we will come back to the assignment in Chapter 4.4.4 “Assignment Operators” on page 78. These nuances are better understood with some more background, and for now it is enough to be able to assign values to variable.