[R] tkProgressBar without progress in foreach %dopar%

Alexsandro Cândido de Oliveira Silva acos at dpi.inpe.br
Thu Oct 2 17:40:54 CEST 2014


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



    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





____________________________________________________________________________
_______





---
Este email está limpo de vírus e malwares porque a proteção do avast! Antivírus está ativa.
http://www.avast.com

	[[alternative HTML version deleted]]



More information about the R-help mailing list