-
-
Save thierrymoudiki/54f7c6a220270eb7ca2ffdd7816aa46f to your computer and use it in GitHub Desktop.
Progress bars with foreach and doSNOW
This file contains hidden or 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