title: Renaming matrix rows in R
body: <p>I have the following matrix:</p>
  
  <pre><code>&gt; dat
  
         [,1]      [,2]       [,3]        [,4]
  foo 0.7574657 0.2104075 0.02922241 0.002705617
  foo 0.0000000 0.0000000 0.00000000 0.000000000
  foo 0.0000000 0.0000000 0.00000000 0.000000000
  foo 0.0000000 0.0000000 0.00000000 0.000000000
  foo 0.0000000 0.0000000 0.00000000 0.000000000
  foo 0.0000000 0.0000000 0.00000000 0.000000000
  </code></pre>
  
  <p>and given this:</p>
  
  <pre><code>&gt; new_names &lt;- c("f0","f1","f2","f3","f4","f5");
  # where the length of new_names matches the number of rows in the dat matrix
  </code></pre>
  
  <p>How can I get this?</p>
  
  <pre><code>        [,1]      [,2]       [,3]        [,4]
  f0 0.7574657 0.2104075 0.02922241 0.002705617
  f1 0.0000000 0.0000000 0.00000000 0.000000000
  f2 0.0000000 0.0000000 0.00000000 0.000000000
  f3 0.0000000 0.0000000 0.00000000 0.000000000
  f4 0.0000000 0.0000000 0.00000000 0.000000000
  f5 0.0000000 0.0000000 0.00000000 0.000000000
  </code></pre>