[R] problem with matrix multiplication

Marlene Mueller Marlene.Mueller at gmx.de
Wed May 23 19:10:17 CEST 2001

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[1] .... 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

More information about the R-help mailing list