Learn R Programming

coenocliner (version 0.2-3)

expand: An expand.grid-like function that repeats sets of vectors for every value in a reference vector.

Description

The values of x are repeated for each combination of elements in the vectors supplied via ..., with the first elements of each vector in ... being taken as a set, the second elements as another set, and so on. x is repeated for each of these sets.

Usage

expand(x, ...)

Arguments

x

numeric; vector of data points which are to be replicated for each of the sets of vectors supplied to ....

...

additional vector arguments to be expanded to the correct length. These are taken to be a set of values to be replicated for each of the elements of x.

Value

a matrix of replicated vectors, with column names for x and named arguments passed as ....

References

Minchin P.R. (1987) Simulation of multidimensional community patterns: towards a comprehensive model. Vegetatio 71, 145--156.

Examples

Run this code
# NOT RUN {
# Recreate Fig. 2 of Minchin (1987)
# Parameters for each of 6 six species
A0 <- c(5,4,7,5,9,8) * 10
m <- c(25,85,10,60,45,60)
r <- c(3,3,4,4,6,5) * 10
alpha <- c(0.1,1,2,4,1.5,1)
gamma <- c(0.1,1,2,4,0.5,4)
# Gradient locations
x <- 1:100

# expand parameter set
pars <- expand(x, m = m, A0 = A0, r = r, alpha = alpha,
               gamma = gamma)
head(pars)
# }

Run the code above in your browser using DataLab