title: Rcpp Basic Numeric Matrix Example Error
body: <p>I am currently trying to figure out how to use Rcpp and have been going through the examples listed at <a href="http://adv-r.had.co.nz/Rcpp.html" rel="nofollow">this</a> website. I've been able to get through all the examples up until the examples involving matrices. For example, the following code has been giving me trouble. I've separated the code into a .r file listed below    </p>
  
  <pre><code># rcpp_test.r     
  
  require( Rcpp )
  
  
  test&lt;-function(x){
  
      cppFunction('NumericVector rowSumsC(NumericMatrix x) {
  
        int nrow = x.nrow(), ncol = x.ncol();
  
        NumericVector out(nrow);
  
        for (int i = 0; i &lt; nrow; i++) {
  
          double total = 0;
  
          for (int j = 0; j &lt; ncol; j++) {
            total += x(i, j);
          }
  
          out[i] = total;
        }
  
        return out;
     }')  
  
     return(rowSumsC(x))
  }
  </code></pre>
  
  <p>Now when I do the following I get an error message</p>
  
  <pre><code>&gt; source('rcpp_test.r')
     Loading required package: Rcpp
  &gt; x &lt;- matrix(c(1,2,3,4,5,6,7,8,9), byrow=T, nrow=3)
  &gt; test(x)
     Error in rowSumsC(x) : 
   INTEGER() can only be applied to a 'integer', not a 'NULL'
  </code></pre>
  
  <p>Not sure where this: INTEGER() can only be applied to a 'integer', not a 'NULL' error is coming from which is sad because getting the NumericMatrix object to work would be pretty cool. Any help or advice would be appreciated</p>
  
  <p>Edit:</p>
  
  <p>I have included sessionInfo()</p>
  
  <pre><code>&gt; sessionInfo()
  
  R version 3.1.1 (2014-07-10)
  Platform: x86_64-w64-mingw32/x64 (64-bit)
  
  locale:
  [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
  [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
  [5] LC_TIME=English_United States.1252    
  
  attached base packages:
  [1] stats     graphics  grDevices utils     datasets  methods   base     
  
  other attached packages:
  [1] Rcpp_0.11.2
  
  loaded via a namespace (and not attached):
  [1] tools_3.1.1
  </code></pre>