title: R - parallelizing ldply and replicate functions
body: <p>I have tried for quite some time to parallelize this code, to no avail. I either get errors or nothing works. Anyone have any ideas?</p>
  
  <pre><code>cal_Ops &lt;- function(n, dtm, ratio = 0.1) {
    print(n)
    selVect &lt;- sample(nrow(dtm), nrow(dtm) * ratio)
    holdout &lt;- dtm[selVect,]
    training &lt;- dtm[-selVect,]
    topModel &lt;- LDA(training, n, control = list(estimate.alpha = FALSE))
    return(c(n, perplexity(topModel, holdout), as.numeric(logLik(topModel))))
  }
  
  require(plyr)
  
  replication &lt;- 1000
  
  sequ &lt;-seq(5,100,5)
  
  perplex &lt;- ldply(sequ, function(x, dtm) {
     t(replicate(replication, cal_Ops(x, dtm))) } , dtm = DTM_to_use)
  </code></pre>
  
  <p>It takes a LONG time to run as is. Thank you, in advance.</p>
  
  <p>I've tried using this example as a parallel version of replicate - but, I had many errors: 
  <a href="https://stackoverflow.com/a/19281611/8598566">https://stackoverflow.com/a/19281611/8598566</a> </p>