raply {plyr}R Documentation

Replicate expression and return results in a array

Description

Evalulate expression n times then combine results into an array

Usage

raply(.n, .expr, .progress = "none", .drop = TRUE)

Arguments

.n number of times to evaluate the expression
.expr expression to evaluate
.progress name of the progress bar to use, see create_progress_bar
.drop

Details

This function runs an expression multiple times, and combines the result into a data frame. If there are no results, then this function returns a vector of length 0 (vector(0)). This function is equivalent to replicate, but will always return results as a vector, matrix or array.

@keyword manip @arguments number of times to evaluate the expression @arguments expression to evaluate @arguments name of the progress bar to use, see create_progress_bar @value if results are atomic with same type and dimensionality, a vector, matrix or array; otherwise, a list-array (a list with dimensions)

Value

if results are atomic with same type and dimensionality, a vector, matrix or array; otherwise, a list-array (a list with dimensions)

Author(s)

Hadley Wickham <h.wickham@gmail.com>

Examples

raply(100, mean(runif(100)))
raply(100, each(mean, var)(runif(100)))

raply(10, runif(4))
raply(10, matrix(runif(4), nrow=2))

# See the central limit theorem in action
hist(raply(1000, mean(rexp(10))))
hist(raply(1000, mean(rexp(100))))
hist(raply(1000, mean(rexp(1000))))

[Package plyr version 0.1.5 Index]