I have a R
script called parallel_progress_reprex.R
that executes code in parallel and tracks the progress using progressr
:
library(progressr) ## use progressr for procession updates
library(doFuture) ## attaches also foreach and future
registerDoFuture() ## tell foreach to use futures
plan(multisession) ## parallelize over a local PSOCK cluster
xs <- 1:8
with_progress({
p <- progressor(along = xs)
y <- foreach(x = xs) %dopar% {
p()
Sys.sleep(1)
sqrt(x)
}
})
When executed in the interactive mode or with source("parallel_progress_reprex.R")
this displays a progress bar which tracks my progress. However, when I use the rstudioapi::jobRunScript
command the progress bar is not displayed anymore.
rstudioapi::jobRunScript("parallel_progress_reprex.R")
How can the progress bar be forced to show up using rstudioapi::jobRunScript
?