title: Increasing the efficiency of when looping over a user defined function which requires multiple dataframes as arguments
body: <p>I apologise if this is an extremely simple question but I do not seem to be able to find a workable solution. I have created a function which requires three inputs, two data frames and a single value. I need to run this function multiple times with the same inputs, but a different seed. I have managed to create a for loop, like the one below, that does what I need but it is really slow. I was wondering if there is any way of increasing the speed of this loop. I have tried to use lapply and purr::map but I do not seem to be able to get the multiple inputs in as required. </p>
  
  <pre><code>#Simple example version of the code I have for demonstration
  library(dplyr)
  exampe_function &lt;- function(df1 ,df2, singlevalue){
    df3 &lt;- sample_frac(df1, size = 1, replace = TRUE)
    temp &lt;- df3[1] + df2[1]
    out &lt;- temp[1,1] * singlevalue #Only need a single value
    return(out)
  }
  
  example_df1 &lt;- data.frame(x = rnorm(10), y = rnorm(10))
  example_df2 &lt;- data.frame(x = rnorm(10), y = rnorm(10))
  singlevalue &lt;- 0.5
  
  test &lt;- exampe_function(example_df1, example_df2, singlevalue)
  
  test_list &lt;- list()
  for (i in 1:10) {
    print(i)
    t &lt;- exampe_function(example_df1, example_df2, singlevalue)
    test_list &lt;- c(test_list, t)
  }
  
  unlist(test_list)
  </code></pre>
  
  <p>Thanks for the help in advance </p>