[R] Matrix multiplication ...
Paul Gilbert
pgilbert at bank-banque-canada.ca
Thu Nov 1 18:19:00 CET 2001
>I know that %*% is used for matrix multiplication. However, if I
>multiply t(Y) %*% Y, where Y is an n by 1 vector, then the product is
>a scalar.
No, it is a 1 x 1 matrix. c(t(Y) %*% Y) is a scalar and should work:
> Y <- matrix(1:5,5,1)
> t(Y) %*% Y
[,1]
[1,] 55
> is.matrix(t(Y) %*% Y)
[1] TRUE
> is.matrix(c(t(Y) %*% Y))
[1] FALSE
Paul Gilbert
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list