title: Run a R function with multiple parameters in parallel mode
body: <p>I have the function </p>
  
  <pre><code>function1 &lt;- function(df1, df2, int1, int2, char1)
  {
  ...
  return(newDataFrame)
  }
  </code></pre>
  
  <p>which has 5 inputs: the first 2 are data frames, then I have two integers and a string. 
  The function returns a new data frame. </p>
  
  <p>So far I am running this function 8 times sequentially: </p>
  
  <pre><code>newDataFrame1 &lt;- function1(df1, df2, 1, 1, "someString")
  newDataFrame2 &lt;- function1(df1, df2, 2, 0, "someString")
  newDataFrame3 &lt;- function1(df1, df2, 3, 0, "someString")
  newDataFrame4 &lt;- function1(df1, df2, 4, 0, "someString")
  newDataFrame5 &lt;- function1(df1, df2, 5, 0, "someString")
  newDataFrame6 &lt;- function1(df1, df2, 6, 0, "someString")
  newDataFrame7 &lt;- function1(df1, df2, 7, 0, "someString")
  newDataFrame8 &lt;- function1(df1, df2, 8, 0, "someString")
  </code></pre>
  
  <p>and at the end I am combining results using rbind():</p>
  
  <pre><code>newDataFrameTot &lt;-  rbind(newDataFrame1, newDataFrame2, newDataFrame3, newDataFrame4, newDataFrame5, newDataFrame6, newDataFrame7, newDataFrame8)
  </code></pre>
  
  <p>I wanted to run this in parallel using library(parallel) but I'm not able to figure out how to make this work. I am trying: </p>
  
  <pre><code>cluster &lt;- makeCluster(detectCores())
  result &lt;- clusterApply(cluster,1:8,function1)
  newDataFrameTot &lt;- do.call(rbind,result)
  </code></pre>
  
  <p>but this don't work unless my function function1() has only one parameter that I loop from 1 to 8. But this is not my case since I need to pass 5 inputs. 
  How can I make this work in parallel? </p>