#!/usr/bin/env Rscript library(parallel) library(MASS) args = commandArgs(trailingOnly=TRUE) if (length(args)==0) { args[1] = 1 } numCores <- args[1] x <- iris[which(iris[,5] != "setosa"), c(1,5)] trials <- seq(1, 10000) boot_fx <- function(trial) { ind <- sample(100, 100, replace=TRUE) result1 <- glm(x[ind,2]~x[ind,1], family=binomial(logit)) r <- coefficients(result1) res <- rbind(data.frame(), r) } system.time({ results <- mclapply(trials, boot_fx, mc.cores = numCores) })