title: R cannot assign row names to the matrix output of get()
body: <p>I am looking to assign row names to a matrix using R's rownames() function. I have a string that contains the name of my matrix, a list of row names I want to assign, and get the value of matrix name via the get() function.</p>
  
  <p>Calling rownames() on just the output of the get() function throws an error, but if I assign the output of get() to a variable THEN use rownames() it works.</p>
  
  <pre class="lang-r prettyprint-override"><code>mat = "matrix1"  # the name of my matrix variable, as a string
  components = c("1", "2", "3")  # my row names
  
  temp = get(mat)  # temp now holds the value of matrix1
  
  # This fails
  &gt; rownames(get(mat)) = components
  Error in rownames(get(mat)) = components : 
    could not find function "get&lt;-"
  
  # But this works
  &gt; rownames(temp) = components
  &gt;
  </code></pre>
  
  <p>I understand that this is an easy workaround, simply assigning the get() output to a variable, I am just new to R and am very interested as to why my nested function calls don't work.</p>
  
  <p>I would expect R to simply output a matrix with my new row names to the terminal and then terminate.</p>