Hello, I have a bootstrap implementation loop that I would like to replace by a faster "batch operator".
The loop is as follows: for (b in 1:B) { indices <- sample(1:N, size=N, replace=TRUE) # sample n elements with replacement theta_star[b,] = statistic(data,indices) # execute statistic callback function } I would like to replace this by something like (does not work): indices <- replicate(B,sample(1:N, size=N, replace=TRUE)) theta_star <- apply(indices,2,statistic,data) This, however, does not work because the statistic function receives indices as second parameter and not as first parameter. While I could change the signature of my statistic function I would like to know how to achieve this without having to do so. TIA, Best regards, Giovanni [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.