[R] Waiting bar
Henrik Bengtsson
hb at stat.berkeley.edu
Wed Jan 30 19:11:58 CET 2008
For text-based progress bars see the ProgressBar class in R.utils, e.g.
# A "faster" progress bar with default step length 1.4.
pb <- ProgressBar(max=42, stepLength=1.4)
reset(pb)
while (!isDone(pb)) {
x <- rnorm(3e4)
increase(pb)
Sys.sleep(0.02)
}
cat("\n")
Output: [.........|.........|.........|.........|.]
print(pb)
[1] "ProgressBar: max=42, value=42"
See also subclass FileProgressBar, which instead of writing to stdout
writes to a file in way that the file size equals the progress. This
is useful when you batch process jobs in the background and a simple
'ls -l' via ssh or a 'dir' via ftp will tell you the progress of an R
job.
There is also TextStatusBar, e.g. example(TextStatusBar) gives:
...
Processing array.html (3.35kB)
Processing as.data.frame.html (4.23kB)
Processing as.environment.html (1.63kB)
Processing as.function.html (2.28kB)
Processing as.POSIXlt.html (5.97kB)
File: args.html [ 4% 3822 lines 10:10:19]
Hard to explain what it looks like, but try it. (If you run Rgui on
Windows make sure to turn off buffered output).
/Henrik
On Jan 30, 2008 9:35 AM, tintin_et_milou <loic.joffre at gmail.com> wrote:
>
> Hi,
>
> I would like to know if it is possible to generate a waiting bar in R when
> you execute your programs like in Matlab, to make the program more living.
> Particularly for the loops, it can be useful to know how many time left...
>
> Thanks in advance,
>
> Loïc Joffre
> --
> View this message in context: http://www.nabble.com/Waiting-bar-tp15186895p15186895.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list