Читать книгу The Big R-Book - Philippe J. S. De Brouwer - Страница 117
4.4.1 Arithmetic Operators
Оглавлениеarithmetic – operators
Arithmetic operators act on each element of an object individually.
operator – arithmetic
v1 <- c(2,4,6,8) v2 <- c(1,2,3,5) v1 + v2 # addition ## [1] 3 6 9 13 v1 - v2 # subtraction ## [1] 1 2 3 3 v1 * v2 # multiplication ## [1] 2 8 18 40 v1 / v2 # division ## [1] 2.0 2.0 2.0 1.6 v1 %% v2 # remainder of division ## [1] 0 0 0 3 v1 %/% v2 # round(v1/v2 -0.5) ## [1] 2 2 2 1 v1 ∧ v2 # v1 to the power of v2 ## [1] 2 16 216 32768
addition
substraction
multiplication
division
power