0

I need to parallelize a while loop in R, in order to gain better performance. Is this always possible? In my case, I need to compute BTM models and their coherence in order to evaluate different models. THe loop is extremely simple:

  while(i<=to)
  {
    row=row+1
    df$Topic[row]<-i
    BTM_model<-BTM(data=token, i)
    df$MeanCoherence<-mean(coherenceBTM(model = BTM_model, DTM, N=15))
    i=i+by
  }

I don't wan this to seem like a homework, so just an explanation about how to implement this would be extremely useful!

  • 1
    Does this answer your question? [run a for loop in parallel in R](https://stackoverflow.com/questions/38318139/run-a-for-loop-in-parallel-in-r) – mhovd Jan 02 '21 at 16:56
  • I am sorry, I linked the wrong question. This answer talks about the `future` package: https://stackoverflow.com/a/43150606/3212698 – mhovd Jan 02 '21 at 16:57
  • 1
    Does this answer your question? [Parallel while loop in R](https://stackoverflow.com/questions/43121109/parallel-while-loop-in-r) – Jan Jan 02 '21 at 17:37

0 Answers0