[R] Multiple Vector with matrix in R

frespider frespider at hotmail.com
Fri Nov 16 17:34:56 CET 2012


Hi

Can someone show me an easy way to multiple a weighted vector with an
matrix?

example below
mat1<-matrix(sample(1:100,80,replace=TRUE),ncol=8)
w <- 1/1:10

I want the first element in w to be multiplied by the first row of mat1 and
2nd element in w to be multiplied with the 2nd row and so on.

I have huge matrix is there an easy way other than diag(w)%*%mat1

Thanks



--
View this message in context: http://r.789695.n4.nabble.com/Multiple-Vector-with-matrix-in-R-tp4649764.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list