**Software for Exploratory Data Analysis and Statistical Modelling**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

In designs where there are multiple factors, all with a discrete group of level settings, the full enumeration of all combinations of factor levels is referred to as a **full factorial design**. As the number of factors increases, potentially along with the settings for the factors, the total number of experimental units increases rapidly.

In many cases each factor takes only two levels, often referred to as the low and high levels, the design is known as a 2^k experiment. Given a three factor setup where each factor takes two levels we can create the full factorial design using the **expand.grid** function:

expand.grid(Factor1 = c("Low", "High"), Factor2 = c("Low", "High"), Factor3 = c("Low", "High"))

which creates the following design:

Factor1 Factor2 Factor3 1 Low Low Low 2 High Low Low 3 Low High Low 4 High High Low 5 Low Low High 6 High Low High 7 Low High High 8 High High High

We could also make use of the **gen.factorial** function from the **AlgDesign** package. In this function we use a vector to specify the number of levels for each of the variables, the number of variables and possibly the names of the variables.

To create the full factorial design for an experiment with three factors with 3, 2, and 3 levels respectively the following code would be used:

gen.factorial(c(3,2,3), 3, center=TRUE, varNames=c("F1", "F2", "F3"))

The **center** option makes the level settings symmetric which is a common way of representing the design. The full design is:

F1 F2 F3 1 -1 -1 -1 2 0 -1 -1 3 1 -1 -1 4 -1 1 -1 5 0 1 -1 6 1 1 -1 7 -1 -1 0 8 0 -1 0 9 1 -1 0 10 -1 1 0 11 0 1 0 12 1 1 0 13 -1 -1 1 14 0 -1 1 15 1 -1 1 16 -1 1 1 17 0 1 1 18 1 1 1

**leave a comment**for the author, please follow the link and comment on their blog:

**Software for Exploratory Data Analysis and Statistical Modelling**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.