title: Compile a R-function inside c++ using rcpp
body: <p>I have a function in C++ which has, among others, a function as input-parameter:
  f(int x,int y, Function f). I am using Rcpp to make it available in R, and pass a R function as a parameter.</p>
  
  <p>Passing a R-function as parameter makes it go slower, and especially in a for-loop (because it has to call on the R-function in each iteration). I am wondering if it is possible to 'compile' the R-function once inside the c++ function, but before the actual for-loop? Then it doesn't need to evaluate it outside c++ in each iteration of the for-loop.</p>
  
  <p>I am thinking along the lines of defining a function as a string in R and then get it compiled as a function inside c++. Then it would be actual c++-code? This way, if I made a shiny-app where the user could write his own function-definition as a string, it could get passed threw rcpp to c++ and the for-loop would not be slowed down.</p>
  
  <p>Or, do anyone have a suggestion about how to get around this issue? </p>
  
  <p>My goal is to have a for-loop in c++, for speed, which can use a function defined in R, for convenience.</p>