title: Passing a function argument to other arguments which are functions themselves
body: <p>Assume I have an outer function that has a numeric argument and an argument which is a function itself (inner function). How can I pass the value of the numeric argument of the outer function as an argument to the inner function? Consider this toy example:</p>
  
  <pre><code>innerfun &lt;- function(M){
   1:M
  }
  
  outerfun &lt;- function(x, fun){
   x * fun
  }
  
  outerfun(x = 3, fun = innerfun(M = 3)) ## works
  outerfun(x = 3, fun = innerfun(M = x)) ## error because innerfun can't find 'x'
  outerfun(x = 3, fun = innerfun(M = get("x"))) ## doesn't work either...
  </code></pre>
  
  <p>So what I want to do is to call innerfun at the moment the arguments of outerfun are evaluated, using those outerfun-arguments in the call to innerfun. Any ideas or suggestions?</p>