title: Index element from list in Rcpp
body: <p>Suppose I have a <code>List</code> in Rcpp, here called <code>x</code> containing matrices. I can extract one of the elements using <code>x[0]</code> or something. However, how do I extract a specific element of that matrix? My first thought was <code>x[0](0,0)</code> but that does not seem to work. I tried using <code>*</code> signs but also doesn't work.</p>
  
  <p>Here is some example code that prints the matrix (shows matrix can easily be extracted):</p>
  
  <pre><code>library("Rcpp")
  
  cppFunction(
  includes = ' 
  NumericMatrix RandMat(int nrow, int ncol)
   {
    int N = nrow * ncol;
    NumericMatrix Res(nrow,ncol);
    NumericVector Rands  = runif(N);
     for (int i = 0; i &lt; N; i++) 
    {
      Res[i] = Rands[i];
    }
    return(Res);
   }',
  
  code = '
  void foo()
  {
    List x;
    x[0] = RandMat(3,3);
    Rf_PrintValue(wrap( x[0] )); // Prints first matrix in list.
  }
  ')
  
  
  foo()
  </code></pre>
  
  <p>How could I change the line <code>Rf_PrintValue(wrap( x[0] ));</code> here to print the the element in the first row and column? In the code I want to use it for I need to extract this element to do computations.</p>