title: Calling R function from Rcpp
body: <p>I have a very basic question about C++ integration in R via Rcpp. Suppose I want to implement a simple function like this one in C++:</p>
  
  <pre><code>inte = function(x, y, a, b){
     model = approxfun(x, y)
     return(integrate(model, a, b)$value)
  }
  </code></pre>
  
  <p>So a very basic approach would be to call R's function 'integrate' as much as needed:</p>
  
  <pre><code>// [[Rcpp::export]]
  double intecxx(Function inte, NumericVector x, NumericVector y,
    double a, double b) {  
      NumericVector res;
      res = inte(x, y, a, b);
      return res[0];
  }
  </code></pre>
  
  <p>However, I need to use this 'intecxx' in many other parts of my C++ code, so calling it from somewhere else results in 'inte' not being available in the scope. Any help is appreciated.</p>