[R] problem with matrix multiplication
marlene.mueller at gmx.de
Fri May 25 11:43:49 CEST 2001
Thanks for all solutions! The most elegant & efficient way
seems to me t(t(X)*Y) or t(Y*t(X)). Marlene
Marlene Mueller wrote:
> Hi, I look for a solution to the following problem:
> I have a (n x p) matrix X and a (p x 1) vector Y which
> are to be multiplied such the result is the (n x p) matrix
> Z = ( X[,1]*Y .... X[,p]*Y[p] )
> Up to now I found that sweep(X,2,Y,"*") is (almost) what
> I want, but only for p>1.
> Is there another elegant way to do this by matrix
> operations -- including the case p=1?
> Marlene Mueller
> 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
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