samedi 29 mars 2014

multiply each row in a matrix by a row IN a vector in R


Vote count:

0




I don't want to multiple the entire row by the matrix elementwise. I want to multiply each row of a matrix by its corresponding element in a vector.


It needs to be really fast, too. Does anyone know the quickest way to do this?


for example



oo=matrix(1:3,3,1)
oop=matrix(1:9,3,3,byrow=TRUE)


From those, I want



1 2 3
8 10 12
21 24 27


to be the outputted matrix



asked 53 secs ago






Aucun commentaire:

Enregistrer un commentaire