Skip to content
Snippets Groups Projects
Commit 064e2e78 authored by Dirk Sarpe's avatar Dirk Sarpe
Browse files

add toy example to demonstrate parallelisation

use %do% for single core
use %dopar% for multi core
parent 095a4b55
Branches
No related tags found
No related merge requests found
library(doParallel)
registerDoParallel()
x <- iris[which(iris[,5] != "setosa"), c(1,5)]
trials <- 10000
ptime <- system.time({
r <- foreach(icount(trials), .combine=cbind) %do% {
ind <- sample(100, 100, replace=TRUE)
result1 <- glm(x[ind,2]~x[ind,1], family=binomial(logit))
coefficients(result1)
}
})[3]
ptime
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment