1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
### R code from vignette source 'gettingstartedParallel.Rnw'
###################################################
### code chunk number 1: loadLibs
###################################################
library(doParallel)
cl <- makeCluster(2)
registerDoParallel(cl)
foreach(i=1:3) %dopar% sqrt(i)
###################################################
### code chunk number 2: gettingstartedParallel.Rnw:149-150
###################################################
stopCluster(cl)
###################################################
### code chunk number 3: gettingstartedParallel.Rnw:193-196
###################################################
library(doParallel)
cl <- makeCluster(2)
registerDoParallel(cl)
###################################################
### code chunk number 4: bootpar
###################################################
x <- iris[which(iris[,5] != "setosa"), c(1,5)]
trials <- 10000
ptime <- system.time({
r <- foreach(icount(trials), .combine=cbind) %dopar% {
ind <- sample(100, 100, replace=TRUE)
result1 <- glm(x[ind,2]~x[ind,1], family=binomial(logit))
coefficients(result1)
}
})[3]
ptime
###################################################
### code chunk number 5: bootseq
###################################################
stime <- 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]
stime
###################################################
### code chunk number 6: getDoParWorkers
###################################################
getDoParWorkers()
###################################################
### code chunk number 7: getDoParName
###################################################
getDoParName()
getDoParVersion()
###################################################
### code chunk number 8: gettingstartedParallel.Rnw:274-275
###################################################
stopCluster(cl)
|