
Last chance! 50% off unlimited learning
Sale ends in
x %*% y
drop
to remove
dimensions which have only one level.as.matrix
. Promotion of a vector to a 1-row or 1-column matrix happens when one
of the two choices allows x
and y
to get conformable
dimensions. This operator is S4 generic but not S3 generic. S4 methods need to be
written for a function of two arguments named x
and y
.crossprod()
and
tcrossprod()
are typically preferable.
matrix
, Arithmetic
, diag
.x <- 1:4
(z <- x %*% x) # scalar ("inner") product (1 x 1 matrix)
drop(z) # as scalar
y <- diag(x)
z <- matrix(1:12, ncol = 3, nrow = 4)
y %*% z
y %*% x
x %*% z
Run the code above in your browser using DataLab