Читать книгу The Big R-Book - Philippe J. S. De Brouwer - Страница 69

Note – Percentage signs point towards matrix operations

Оглавление

Note that matrices will accept both normal operators and specific matrix operators.

# Note the difference between the normal product: A * A ## [,1] [,2] [,3] ## [1,] 0 1 4 ## [2,] 9 16 25 ## [3,] 36 49 64 # and the matrix product %*%: A %*% A ## [,1] [,2] [,3] ## [1,] 15 18 21 ## [2,] 42 54 66 ## [3,] 69 90 111 # However, there is -of course- only one sum: A + A ## [,1] [,2] [,3] ## [1,] 0 2 4 ## [2,] 6 8 10 ## [3,] 12 14 16 # Note that the quotients yield almost the same: A %/% A ## [,1] [,2] [,3] ## [1,] NA 1 1 ## [2,] 1 1 1 ## [3,] 1 1 1 A / A ## [,1] [,2] [,3] ## [1,] NaN 1 1 ## [2,] 1 1 1 ## [3,] 1 1 1

The same hold for quotient and other operations.

The Big R-Book

Подняться наверх