title: How to pass a function from a list of function to another function with in a function?
body: <p>I want to pass a list of functions to a function which passes each of the functions to a second function. The following code works for a single function but does not work for a list of functions.</p>
  <pre><code>df &lt;- as.data.frame(...)
  parameters &lt;- list(c(1,2), c(1,2)
  model_1 &lt;- function(parameters, df){...}
  model_2 &lt;- function(parameters, df){...}
  models &lt;- c(model_1, model_2)
  
  find_the_best_model &lt;- function(models, df, parameters){
      est &lt;- rep(0, length(models))
      for (i in 1:length(models)){
         model &lt;- models[1]
         parameter &lt;- as.numeric(unlist(parameters[i])
         est[i] &lt;- optim(par = parameter , fn = model, data = df)
      }
      return(est)
  }
  
  find_the_best_model(models, df, parameters) 
  </code></pre>
  <p>How do I pass a list of functions to the above function?</p>