Last active
September 8, 2015 04:41
-
-
Save jeffreyhanson/181313ea9aed85f32975 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(snow) | |
library(plyr) | |
library(doSNOW) | |
library(compiler) | |
data(mtcars) | |
ratio=cmpfun( | |
function(x, w) { | |
return(mean((x$mpg * w) / (x$wt * w))) | |
} | |
) | |
clust=makeCluster(4, "SOCK") | |
clusterEvalQ(clust, {library(boot)}) | |
clusterExport(clust, c("ratio", "mtcars")) | |
registerDoSNOW(clust) | |
result=llply( | |
seq_len(10), | |
.parallel=TRUE, | |
.fun=function(i) { | |
return(boot(data=mtcars, statistic=ratio, 1)) | |
} | |
) | |
clust=stopCluster(clust) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment