title: How do I extract rownames from a matrix?
body: <p>I have a matrix with rownames that are dates. I want to extract these row names into a variable, and then use rownames() to apply these dates to another matrix I have. Let's say the matrix is called 'data.matrix'.</p>
  
  <p>Whenever I run:</p>
  
  <pre><code>data.matrix[,0]
  </code></pre>
  
  <p>I get a printout of all the dates. So I do this:</p>
  
  <pre><code>v &lt;- data.matrix[,0]
  </code></pre>
  
  <p>When I return v I get a nice list of all the dates. But when I use:</p>
  
  <pre><code>rownames(other.matrix) &lt;- v
  </code></pre>
  
  <p>And then I return:</p>
  
  <pre><code>head(other.matrix)
  </code></pre>
  
  <p>I don't get any new column names. </p>
  
  <p>Also, when I try:</p>
  
  <pre><code>head(v)
  </code></pre>
  
  <p>I get <code>NULL</code></p>
  
  <p>But when I do:</p>
  
  <pre><code>v
  </code></pre>
  
  <p>I get a nice printout of all my dates.</p>
  
  <p>So what gives? At first I thought that matrices and dates were incompatible but it seems as if they are. </p>
  
  <p>Right now I'm using <code>merge()</code> in this way to add dates:</p>
  
  <pre><code>z &lt;- merge(v, other.matrix)
  </code></pre>
  
  <p>But it feels like there's a better way to do this.</p>