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
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
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment