I have
mat<-matrix(1:12,3) vect<-c(2,2,2)
How can I multiply each column by the vector in order to obtain:
2, 8, 14, 20 4, 10, 16, 22 6, 12, 18, 24
vect*mat [,1] [,2] [,3] [,4] [1,] 2 8 14 20 [2,] 4 10 16 22 [3,] 6 12 18 24
The vector vect is recycled by column. Better to experiment with different values to see the process.
vect
The vector
vect
is recycled by column. Better to experiment with different values to see the process.