[R] txtProgressBar and parallelized foreach

Julian TszKin Chan cjulian at bu.edu
Tue Jun 14 12:23:48 CEST 2011


Hi all,

I can create a text-progress bar in a foreach loop by the following code :

n=10
foreach( i = 1:n ,.combine=c) %do%{
	setTxtProgressBar(pb, i)
	Sys.sleep(0.1)
}


However, once i use the parallelized foreach, the text-progress bar
disappear.  Any solution to this problem? How can i create a progress
bar in parallelized foreach? Thanks

cl<-makeCluster(core)
registerDoSNOW(cl)

pb<-txtProgressBar(min = 0, max = n, style = 3)
foreach( i = 1:n ,.combine=c) %dopar%{
	setTxtProgressBar(pb, i)
	Sys.sleep(0.1)
}
close(pb)
stopCluster(cl)


Regards,
TszKin Julian



More information about the R-help mailing list