mcsapply: A multicore version of sapply() (For Windows only)

Description Usage Arguments Examples

View source: R/ex.R

Description

A multicore version of sapply() (For Windows only)

Usage

1
mcsapply(cluster, X, FUN, ...)

Arguments

cluster

cluster

X

object of the function

FUN

function

...

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 
cores = detectCores()
cluster = makePSOCKcluster(cores)
boot_i = function(i){
r_adj = function(x,id) {
  x = x[id,]     #bootstrap sample
  res = lm(mpg~wt+disp,data=x)
  summary(res)$adj.r.squared
}
as.numeric(boot::boot(mtcars,r_adj,1)$t)
}
system.time(sapply(1:500,boot_i))
system.time(mcsapply(cluster,1:500,boot_i))

## End(Not run)

XixuHu/SC19090 documentation built on Jan. 2, 2020, 8:40 p.m.