papply | R Documentation |
Detects and opens cores for simpler parallel lapply.
papply(X, FUN, ..., cores = 1, outfile = "", msg = NULL, pb = TRUE)
X , FUN , ... |
See lapply. |
cores |
An integer giving the number of cores to run the function FUN over. |
outfile |
Set this to FALSE to suppress printing from the cores. |
msg |
A message to pring to the console, followed by the number of runs (and the number of cores in the case of parallel processing). |
pb |
Logical: If FALSE suppress the progress bar. |
f <- function(i){
for(j in 1:3){
for(k in 1:500){
Sys.sleep(0.001)
d <- runif(100)
}
}
}
system.time(p <- papply(1:4, f, cores=1))
system.time(p <- papply(1:4, f, cores=2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.