title: Getting elements of a list in R
body: <p>This is my problem: </p>
  
  <p>There is a predefined list named <code>gamma</code> with three entries: <code>gamma$'2'</code> is 2x2 matrix <code>gamma$'3'</code> a 3x3 matrix and <code>gamma$'4'</code> a 4x4 matrix. I would like to have function that returns the matrix I need:</p>
  
  <pre><code>GiveMatrix &lt;- function(n) {
      gamma.list &lt;- #init the list of matrices
  
      gamma.list$n  # return the list entry named n
  </code></pre>
  
  <p>Since <code>n</code> is not a character, the last line does not work. I tried <code>gamma.list$paste(n)</code>and <code>gamma.list$as.character(n)</code>but both did not work. Is there a function that converts <code>n</code>to the right format? Or is there maybe a much better way? I know, I am not really good in R. </p>