[R-sig-Geo] foreach progress bar?
Forrest Stevens
forrest at ufl.edu
Mon Feb 25 20:28:20 CET 2013
On Mon, Feb 25, 2013 at 2:12 PM, Jonathan Greenberg <jgrn at illinois.edu> wrote:
> Folks:
>
> Has anyone figured out a general solution to create a foreach progress
> bar, updated as each iteration is completed?
>
> --j
The following is what I use frequently, but you should note that the
raster package (assuming that's what you'd like it for) has facilities
built in for progress bar creation:
## NOTE: The tcltk library is used to create a progress bar, but the
## raster package has a progress bar mechanism built in in recent versions.
## Look up the pbCreate(), pbStep(), and pbClose() functions in the raster
## package...
require(tcltk)
total_n <- 1000
pb <- tkProgressBar(title = "Predicting Population Density:", min = 0,
max = total_n, width = 300)
for (i in 1:total_n) {
## ...
setTkProgressBar(pb, i, label=paste( round(i/total_n*100, 0),"% done"))
}
close(pb)
Forrest Stevens
--
Ph.D. Candidate, QSE3 IGERT Fellow
Department of Geography
Land Use and Environmental Change Institute
University of Florida
www.clas.ufl.edu/users/forrest
More information about the R-sig-Geo
mailing list