title: Multiply rows of matrix by vector?
body: <p>I have a numeric <code>matrix</code> with 25 columns and 23 rows, and a vector of length 25. How can I multiply each row of the matrix by the vector without using a <code>for</code> loop?</p>
  
  <p>The result should be a 25x23 matrix (the same size as the input), but each row has been multiplied by the vector.</p>
  
  <p><strong>Added reproducible example from @hatmatrix's answer:</strong></p>
  
  <pre><code>matrix &lt;- matrix(rep(1:3,each=5),nrow=3,ncol=5,byrow=TRUE)
  
       [,1] [,2] [,3] [,4] [,5]
  [1,]    1    1    1    1    1
  [2,]    2    2    2    2    2
  [3,]    3    3    3    3    3
  
  vector &lt;- 1:5
  </code></pre>
  
  <p><strong>Desired output:</strong></p>
  
  <pre><code>     [,1] [,2] [,3] [,4] [,5]
  [1,]    1    2    3    4    5
  [2,]    2    4    6    8   10
  [3,]    3    6    9   12   15
  </code></pre>