Description Usage Arguments Details Value Examples
A progress bar that uses files to store progress counters with the intention that it can be used together with parallel computations.
1 2 |
N |
a |
initial |
a |
char |
a |
width |
a |
totalBar |
a |
file |
a |
pid |
a |
This progress bar is based on txtProgressBar
. However, instead of using
a local variable associated with the progress bar object to keep track of the progress, this progress
bar uses files to store the progress. The intention is that the progress bar works
even when computations are carried out in parallel. It works by setting the total number N
of iterations when creating the progressBar
object. In each interation a
counter is incremented, and the progress bar is updated with the percentage of completion
as measured by the current value of the counter relative to N
.
It has only been tested with mclapply
from the parallel
package.
Option pid = TRUE
only gives meaningful results in this case when mc.preschedule = TRUE
for mclapply
(which is the default).
With a huge number of interations and little work in each, the file IO can produce a serious overhead.
An object of class progressBar
containing two functions up
and kill
.
Call up()
to increment the counter and update the progress bar. Remember
to call kill()
after the progress bar is used to clean up.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | pb <- progressBar(100)
for(i in 1:100) {
Sys.sleep(0.1)
pb$up()
}
pb$kill() ## Remember this to clean up. Removes files and directories used.
rm(pb)
## Not run:
pb <- progressBar(100)
library(parallel)
tmp <- mclapply(1:100, function(i) {
Sys.sleep(0.1)
pb$up()
}
)
pb$kill() ## Remember this to clean up. Removes files and directories used.
rm(pb)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.