Re: [R] Waiting bar

From: Henrik Bengtsson <hb_at_stat.berkeley.edu>
Date: Wed, 30 Jan 2008 10:11:58 -0800

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,
>
> Loc 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.
>



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. Received on Wed 30 Jan 2008 - 18:18:33 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 30 Jan 2008 - 19:30:09 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive