lokheart lokheart - 1 year ago 33
R Question

The R %*% operator

What is this? I can't find help by using

?
. (Sorry for being dumb)

> 1%*%1
[,1]
[1,] 1
> 10%*%10
[,1]
[1,] 100
> c(1:2)%*%c(1:2)
[,1]
[1,] 5

Answer Source

It's a matrix multiplication operator!

From the documentation:

Description:

Multiplies two matrices, if they are conformable. If one argument is a vector, it will be promoted to either a row or column matrix to make the two arguments conformable. If both are vectors of the same length, it will return the inner product (as a matrix).

Usage:

x %*% y

Arguments:

x, y    numeric or complex matrices or vectors

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download