In this summary {agricolae} is used to generate a few common experimental designs based on a given number of treatment factor levels and a number of desired replicates (see “Example Setup” below). Additionally, each experimental design that was generated is also plotted using {desplot} so that different designs can be compared easily.
# packages
::p_load(tidyverse, # data handling
pacman# experimental design
agricolae, # plots desplot)
# 2 pesiticides
<- paste0("P", 1:2) # P1 & P2
TrtPest <- n_distinct(TrtPest) # 2
n_TrtPest
# 4 soil treatments
<- paste0("S", 1:4) # S1 - S4
TrtSoil <- n_distinct(TrtSoil) # 4
n_TrtSoil
# 6 fertilizer
<- paste0("N", 1:6) # N1 - N6
TrtFert <- n_distinct(TrtFert) # 6
n_TrtFert
# 15 genotpyes
<- paste0("G", 1:15) # G1 - G15
TrtGen <- n_distinct(TrtGen) # 15
n_TrtGen
# 2 check varieties
<- c("Std_A", "Std_B")
Checks
# number of replicates
<- 3 n_Reps
completely randomized design
<- design.crd(trt = TrtSoil,
crd_out r = n_Reps,
seed = 42)
# Add Row and Col
$bookRowCol <- crd_out$book %>%
crd_outbind_cols(expand.grid(Row = 1:n_Reps,
Col = 1:n_TrtSoil))
# Plot field layout
desplot(TrtSoil ~ Row + Col, flip = TRUE,
text = TrtSoil, cex = 1, shorten = "no",
data = crd_out$bookRowCol,
main = "completely randomized design",
show.key = F)
randomized complete block design
<- design.rcbd(trt = TrtSoil,
rcbd_out r = n_Reps,
seed = 42)
# Add Row and Col
$bookRowCol <- rcbd_out$book %>%
rcbd_outmutate(Row = block %>% as.integer) %>%
group_by(Row) %>%
mutate(Col = 1:n()) %>%
ungroup()
# Plot field layout
desplot(TrtSoil ~ Row + Col, flip = TRUE,
text = TrtSoil, cex = 1, shorten = "no",
out1 = block,
data = rcbd_out$bookRowCol,
main = "randomized complete block design",
show.key = T, key.cex = 0.5)
<- design.lsd(trt = TrtSoil,
latsquare_out seed = 42)
# Add Row and Col
$bookRowCol <- latsquare_out$book %>%
latsquare_outmutate(Row = row %>% as.integer,
Col = col %>% as.integer)
# Plot field layout
desplot(TrtSoil ~ Row + Col, flip = TRUE,
out1 = Row, out1.gpar=list(col="black", lwd=3),
out2 = Col, out2.gpar=list(col="black", lwd=3),
text = TrtSoil, cex = 1, shorten = "no",
data = latsquare_out$bookRowCol,
main = "latin square design",
show.key = T, key.cex = 0.5)
<- design.alpha(trt = TrtGen,
alpha_out k = 3,
r = n_Reps,
seed = 42)
# Add Row and Col
$bookRowCol <- alpha_out$book %>%
alpha_outmutate(replication = paste0("Rep", replication),
Row = block %>% as.integer,
Col = cols %>% as.integer)
# Plot field layout
desplot(TrtGen ~ Row + Col | replication, flip = TRUE,
out1 = replication,
out2 = block, out2.gpar = list(col = "black", lty = 3),
text = TrtGen, cex = 1, shorten = "no",
data = alpha_out$bookRowCol,
main = "alpha design",
show.key = F)
<- design.dau(trt1 = Checks,
augmented_out trt2 = TrtGen,
r = n_Reps,
seed = 42)
# Add Row and Col
$bookRowCol <- augmented_out$book %>%
augmented_outmutate(Col = block %>% as.integer,
Row = plots %>% str_sub(3,3) %>% as.integer)
# Plot field layout
desplot(trt ~ Row + Col, flip = TRUE,
out1 = block, out1.gpar = list(col = "black", lwd = 2, lty = 3),
text = trt, cex = 1, shorten = "no",
data = augmented_out$bookRowCol ,
main = "augmented design",
show.key = F)
Factorial: You have at least two treatment factors, and all levels of each factor are used in combination with all other factor levels. These factors are said to be cross-classified, as opposed to nested. Additionally, each of the resulting treatment combinations is applied to the same type of experimental unit.
<- design.ab(trt = c(n_TrtFert, n_TrtSoil),
fac2rcbd_out design = "rcbd",
r = n_Reps,
seed = 42)
# Add Row and Col
$bookRowCol <- fac2rcbd_out$book %>%
fac2rcbd_outbind_cols(expand.grid(Row = 1:n_TrtFert,
Col = 1:(n_TrtSoil*n_Reps))) %>%
mutate(TrtFert = paste0("N", A),
TrtSoil = paste0("S", B))
# Plot field layout
desplot(block ~ Col + Row | block, flip = TRUE,
out1 = Row, out1.gpar = list(col = "grey", lty = 1),
out2 = Col, out2.gpar = list(col = "grey", lty = 1),
text = TrtFert, cex = 1, shorten = "no", col=TrtSoil,
data = fac2rcbd_out$bookRowCol,
main = "RCBD",
show.key = T, key.cex = 0.5)
<- design.split(trt1 = TrtSoil,
splitplot_out trt2 = TrtFert,
r = n_Reps,
seed = 42)
# Add Row and Col
$bookRowCol <- splitplot_out$book %>%
splitplot_outmutate(block = paste0("Block", block),
Col = plots %>% str_sub(2,3) %>% as.integer,
Row = splots %>% as.integer)
# Plot field layout
desplot(block ~ Col + Row | block, flip = TRUE,
out1 = Row, out1.gpar = list(col = "grey", lty = 1),
out2 = Col, out2.gpar = list(col = "grey", lty = 1),
text = TrtFert, cex = 1, shorten = "no", col=TrtSoil,
data = splitplot_out$bookRowCol ,
main = "split plot design",
show.key = T, key.cex = 0.5)
<- design.ab(trt = c(n_TrtPest, n_TrtFert, n_TrtSoil),
fac3rcbd_out design = "rcbd",
r = n_Reps,
seed = 42)
# Add Row and Col
$bookRowCol <- fac3rcbd_out$book %>%
fac3rcbd_outbind_cols(expand.grid(Row = 1:(n_TrtFert*n_TrtPest),
Col = 1:(n_TrtSoil*n_Reps))) %>%
mutate(block = paste0("Block", block),
TrtPest = paste0("P", A),
TrtFert = paste0("N", B),
TrtSoil = paste0("S", C))
# Plot field layout
desplot(TrtPest ~ Col + Row | block, flip = TRUE,
out1 = Row, out1.gpar = list(col = "grey", lty = 1),
out2 = Col, out2.gpar = list(col = "grey", lty = 1),
text = TrtFert, cex = 1, shorten = "no", col = TrtSoil,
data = fac3rcbd_out$bookRowCol,
main = "RCBD",
show.key = T, key.cex = 0.5)
Please feel free to contact me about any of this!
schmidtpaul1989@outlook.com