fac.gen {dae}R Documentation

Generate all combinations of several factors and, optionally, replicate them

Description

Generate all combinations of several factors and, optionally, replicate them.

Usage

fac.gen(generate, each=1, times=1, order="standard")

Arguments

generate

A list of named objects and numbers that specify the factors whose levels are to be generated and the pattern in these levels.If a component of the list is named, then the component should be either a) a single numeric value that is the number of levels, b) a numeric vector that contains the levels of the factor, or c) a character vector that contains the labels of the levels of the factor.

each

The number of times to replicate consecutively the elements of the levels generated according to pattern specified by the generate argument.

times

The number of times to repeat the whole generated pattern of levels generated according to pattern specified by the generate argument.

order

Either standard or yates. The order in which the speed of cycling through the levels is to move; combinations of the factors are to be considered as numbered; standard cycles through the levels of the first factor slowest and the last factor moving fastest; yates cycles through the levels of the first factor fastest and last factor moving slowest.

Details

The levels of each factor are generated in a hierarchical pattern, such as standard order, where the levels of one factor are held constant while those of the adjacent factor are cycled through the complete set once. If a number is supplied instead of a name, the pattern is generated as if a factor with that number of levels had been supplied in the same position as the number. However, no levels are stored for this unamed factor.

Value

A data.frame of factors whose generated levels are those supplied in the generate list. The number of rows in the data.frame will equal the product of the numbers of levels of the supplied factors and the values of the each and times arguments.

Warning

Avoid using factor names F and T as these might be confused with FALSE and TRUE.

Author(s)

Chris Brien

See Also

fac.genfactors , fac.combine in package dae

Examples

## generate a 2^3 factorial experiment with levels - and +, and 
## in Yates order
mp <- c("-", "+")
fnames <- list(Catal = mp, Temp = mp, Press = mp, Conc = mp)
Fac4Proc.Treats <- fac.gen(generate = fnames, order="yates")

## Generate the factors A, B and D. The basic pattern has 4 repetitions
## of the levels of D for each A and B combination and 3 repetitions of 
## the pattern of the B and D combinations for each level of A. This basic 
## pattern has each combination repeated twice, and the whole of this 
## is repeated twice. It generates 864 A, B and D combinations.
gen <- list(A = 3, 3, B = c(0,100,200), 4, D = c("0","1"))
fac.gen(gen, times=2, each=2)

[Package dae version 3.2-13 Index]