Skip to content

Instantly share code, notes, and snippets.

@sithjaisong
Created October 16, 2016 08:32
Show Gist options
  • Save sithjaisong/0653ef2713fd9a839b77433243dff1a3 to your computer and use it in GitHub Desktop.
Save sithjaisong/0653ef2713fd9a839b77433243dff1a3 to your computer and use it in GitHub Desktop.
plot.RCBD.layout is the function used to generate layout of randomized complete block design of experiment
library(desplot)
library(agricolae)
library(RColorBrewer)
plot.RCBD.layout <- function(trt_name, num_block){
repeticion <- rep(num_block, length(trt_name))
RCBD <- design.rcbd(trt_name, r = repeticion, serie = 0)
RCBD.layout <- RCBD$book
RCBD.layout$x <- rep(1:num_block, each = length(trt_name))
RCBD.layout$y <- rep(1:length(trt_name), num_block)
desplot(data = RCBD.layout, block ~ x + y, text = trt_name, cex = 2,
col.regions = RColorBrewer::brewer.pal(12, "Set3"),
out1 = block, out2= trt_name,
out1.gpar = list(col = "white", lwd = 5),
out2.gpar=list(col = "white", lwd = 1, lty = 1),
flip = FALSE, show.key = FALSE)
}
# Example
# plot.RCBD.layout(trt_name = c("A","B","C", "D", "E"), 5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment