I do have 3 foreach loops, when I have done all the loops I consider my task as finished.
How can I get one progress bar for all my loops? Suppose that my loops look like this: (I got the functions from this question)
## Parallelization set up
n.cores <- parallel::detectCores() - 1
my.cluster <- parallel::makeCluster(n.cores, type = "PSOCK")
registerDoSNOW(my.cluster)
Q = 100
pb <- progress_bar$new(
format = "Simulation = :Simulation [:bar] :elapsed | Remaining: :eta ",
total = (Q*3),
width = 60)
prog_sim <- 1:Q*3
progress <- function(n){
pb$tick(tokens = list(Simulation = prog_sim[n]))
}
opts <- list(progress = progress)
task_1 <- foreach(i = 1:Q, .combine = rbind, .options.snow = opts) %dopar% {
summary(rnorm(1e6))[3]
}
task_2 <- foreach(i = 1:Q, .combine = rbind, .options.snow = opts) %dopar% {
summary(rnorm(1e6))[3]
}
task_3 <- foreach(i = 1:Q, .combine = rbind, .options.snow = opts) %dopar% {
summary(rnorm(1e6))[3]
}
But in the console, I get these two bars printed, and the last one disappears when finished.
How can I get one big progress bar for several foreach loops?
Thanks in advance