| do {UsingR} | R Documentation |
A function to facilitate performing of simulations
do(.n)
.n |
A positive integer |
This function facilitates simulations. It is called in two steps. The
first sets up a function which will to .n simulations. This
function is then called with a block of commands and returns the simulation.
Returns a function which will repeat a block of commands for purposes of simulation.
do is due to Daniel Kaplan.
Daniel Kaplan
aFew <- do(5)
aLot <- do(100)
## simple call
aFew(mean(rnorm(100)))
## t-statistic simulation
aFew({x <- rexp(10); t.test(x)$stat})
## view correlation of regression coefficients. Returns a data.frame
x <- 1:10
res <- aLot({y <- rnorm(1+2*x); coef(lm(y~x))})
plot(res)