title: assign a function to a variable in R
body: <p>The question is in the title. I'd like to do something like this :</p>
  
  <pre><code>myfunc&lt;- pexp
  plot(function(x) myfunc(x, 0.5))
  </code></pre>
  
  <p>I'd like to call several functions given as parameters in my script. I'd like to use a foreach instead of a bunch of if-then-else statement :</p>
  
  <p>Suppose I call my script this way :</p>
  
  <pre><code>R --slave -f script.R --args plnorm pnorm 
  </code></pre>
  
  <p>I'd like to do something like this :</p>
  
  <pre><code>#only get parameters after --args
  args&lt;-commandArgs(trailingOnly=TRUE)
  for i in args {
      plot(function(x) i(x,param1,param2))
  }
  </code></pre>