Created
October 21, 2015 10:08
-
-
Save andrie/5b4ec4aa39130d8e8b84 to your computer and use it in GitHub Desktop.
Progress bars with foreach and doSNOW
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(doSNOW) | |
library(tcltk) | |
cl <- makeSOCKcluster(2) | |
registerDoSNOW(cl) | |
pb <- txtProgressBar(max=100, style=3) | |
progress <- function(n) setTxtProgressBar(pb, n) | |
opts <- list(progress=progress) | |
r <- foreach(i=1:100, .options.snow=opts) %dopar% { | |
Sys.sleep(1) | |
sqrt(i) | |
} | |
close(pb) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @andrie, thanks for sharing this. Would it be possible to do the same using
doParallel
rather thandoSNOW
?