title: Rcpp and "optional" arguments on functions
body: <p>I need a Rcpp function to behave depending in the type of input. Suppose you want to double every element of a matrix, but if you have no matrix, you return a matrix filled with "2" of a specific dimension. In R it'd be something like:</p>
  
  <pre><code>twoMatrix = function(oldMatrix = NULL, dim=c(10,10)){
   if(!is.null(oldMatrix)){return(2*oldMatrix)}
   return(matrix(2,nrow=dim[1],ncol=dim[2]))
  }
  </code></pre>
  
  <p>But when I try to write the Rcpp function, I'm having trouble on how to define the default values and checking wheter the user has selected one type or another.</p>
  
  <pre><code>#include &lt;Rcpp.h&gt;
  using namespace Rcpp;
  
  // [[Rcpp::export]]
  NumericMatrix twoMatrixRcpp(NumericMatrix OldMatrix, IntegerVector dim){
   ...
  }
  </code></pre>
  
  <p>How do I set default arguments so that it works like R's NULL value in the sense that I can check wheter the user has specified it's value or not? And how to check it inside the function?</p>