Description Usage Arguments Examples
A multicore version of sapply() (For Windows only)
1 |
cluster |
cluster |
X |
object of the function |
FUN |
function |
... |
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.