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)

Commentaires

Posts les plus consultés de ce blog

Standard error from Hessian Matrix... what can be done when problem occurs

stepAIC from package MASS with AICc

Install treemix in ubuntu 20.04