progress bar not working in foreach setting

1.3k Views Asked by At

I have the following foreach setting in Ubuntu system where I need to have a progress-bar to monitor the progress.

library(doMC)
registerDoMC(cores=detectCores()-1)
total <- 9000
# create progress bar
pb <- txtProgressBar(min = 0, max = total, style = 3)
respar <- foreach(i = 1:total, .combine = rbind)%dopar%{
  setTxtProgressBar(pb, i)
  i**3
}
close(pb)

However, the above the implementation is not working but the output in respar is as expected. Could you please comment if there is something wrong with this approach?

Note: The question is to identify the error in this approach of creating the progress-bar. The other similar questions did not deal with this combination of background setup for progress-bar creation.

0

There are 0 best solutions below