do {UsingR}R Documentation

~~function to do ... ~~

Description

A function to facilitate performing of simulations

Usage

do(.n)

Arguments

.n A positive integer

Details

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.

Value

Returns a function which will repeat a block of commands for purposes of simulation.

Note

do is due to Daniel Kaplan.

Author(s)

Daniel Kaplan

See Also

replicate

Examples

 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)

[Package UsingR version 0.1-12 Index]