[R] tkProgressBar without progress in foreach %dopar%

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Oct 2 20:02:51 CEST 2014


On 02/10/2014 16:40, Alexsandro Cândido de Oliveira Silva wrote:
> I have a list (temp.data) with many raster data and some computations are in
> parallel. n is the number of raster data and target is the mask. I'd like to
> use a progress bar. It is created but while the loop is running the progress
> is not showed. The loop ends and the progress bar is closed. I've tried to
> use the functions pdCreate/pdStep in raster package, but without success...
>
> Someone have any idea...

You are using parallel processes here.  You do not tell us what packages 
you are actually using, but my guess is that

setTkProgressBar(mypb, i, title = "R progress bar", label = NULL)

updates a copy of mypb in the worker process, but it is the master 
process which is displaying the progress bar.

But without the complete reproducible example the posting guide asked 
for, we can only guess.

>
>
>
>      mypb <- tkProgressBar(title = "R progress bar", label = "",  min = 0,
> max = n, initial = 0, width = 300)
>
>
>
>      #creating a computing cluster
>
>      cl <- makeCluster(detectCores(),type='SOCK')
>
>      registerDoParallel(cl, cores = detectCores())
>
>
>
>      foreach(i=1:n,.packages=c('tcltk','rgdal','raster')) %dopar% {
>
>        Sys.sleep(.1)
>
>        setTkProgressBar(mypb, i, title = "R progress bar", label = NULL)
>
>
>
>
> temp.data[[i]]<-mask(temp.data[[i]],target,maskvalue=as.numeric(class.outsid
> e))
>
>
> writeRaster(temp.data[[i]],filename=files.list[i],format='GTiff',overwrite=T
> )
>
>      }
>
>
>
>      stopCluster(cl)
>
>      close(mypb)
>
>
>
>
>
> Thanks
>
> Alexsandro
> ______________________________________________
> 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.
>


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford
1 South Parks Road, Oxford OX1 3TG, UK



More information about the R-help mailing list