Learn R Programming

ggdmc (version 0.2.5.2)

MakeLevelArray: Create an array of all factorial combinations of factor levels

Description

Take a list storing one or multiple string vectors and glues the strings in these vectors with a dot symbol.

Usage

MakeLevelArray(x = NA)

Arguments

x

a list storing one or multiple factor vectors. Each vector can have different numbers of level. For example, f <- list(E = c("nc", "wc"), S = c("n", "w", "pn", "pw"))

Value

a table showing the combinations of factor levels.

Examples

Run this code
# NOT RUN {
## Example 1
factors <- list(S = c("s1", "s2"))
MakeLevelArray(factors)
##   S
##  s1   s2
## "s1" "s2"

factors <- list(S = c("left", "right"))
MakeLevelArray(factors)
##      S
##   left   right
##  "left" "right"

## Example 2
factors <- list(A = c("00", "45", "90", "135", "180"),
                S = c("mirror", "normal"))
MakeLevelArray(factors)
##       S
## ------------------------------40
##   A        mirror       normal
## ------------------------------40
##  00   "00.mirror"  "00.normal"
##  45   "45.mirror"  "45.normal"
##  90   "90.mirror"  "90.normal"
## 135  "135.mirror" "135.normal"
## 180  "180.mirror" "180.normal"

## Example 3
factors <- list(E = c("nc", "wc"),
                S = c("n", "w", "pn", "pw"))
MakeLevelArray(factors)

##         S
## -------------------------------40
## E       n      w      pn      pw
## -------------------------------40
## nc "nc.n" "nc.w" "nc.pn" "nc.pw"
## wc "wc.n" "wc.w" "wc.pn" "wc.pw"

# }

Run the code above in your browser using DataLab