Print messages on console during parallel computing
An exemple that print messages during parallel computing
library(pbmcapply) # Can work with mclapply also
cores <- 2
lazyChattySqrt <- function(num, name) {
# Sleep 2 seconds
Sys.sleep(2)
system(sprintf("echo '\nHello\n'"))
return(sprintf("Hello %s, the sqrt of %f is %f.", toString(name), num, sqrt(num)))
}
chattyResult <- pbmclapply(1:3, lazyChattySqrt, "Bob", mc.cores = cores)
cores <- 2
lazyChattySqrt <- function(num, name) {
# Sleep 2 seconds
Sys.sleep(2)
system(sprintf("echo '\nHello\n'"))
return(sprintf("Hello %s, the sqrt of %f is %f.", toString(name), num, sqrt(num)))
}
chattyResult <- pbmclapply(1:3, lazyChattySqrt, "Bob", mc.cores = cores)
Commentaires
Enregistrer un commentaire