Suppose I have a scaling factor such like:
sf<-c(0.9, 0.8, 1.1)
and a matrix:
m0<-matrix(c(1:6), nrow=2, ncol=3)
[,1] [,2] [,3]
[1,] 1 3 5
[2,] 2 4 6
What's the best way to multiply each column of m
with the corresponding element of sf
such like
m1<-matrix(c(0.9, 1.8, 2.4, 3.2, 5.5, 6.6), 2, 3)
[,1] [,2] [,3]
[1,] 0.9 2.4 5.5
[2,] 1.8 3.2 6.6