diff --git a/parallel_example.r b/parallel_example.r new file mode 100644 index 0000000000000000000000000000000000000000..f20124842c38299490c1e298231f55f93b0e2ea6 --- /dev/null +++ b/parallel_example.r @@ -0,0 +1,13 @@ +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