Skip to content

Instantly share code, notes, and snippets.

@sithjaisong
Last active October 16, 2016 08:16
Show Gist options
  • Save sithjaisong/0e97f9aeedd6836e6438e3188240e357 to your computer and use it in GitHub Desktop.
Save sithjaisong/0e97f9aeedd6836e6438e3188240e357 to your computer and use it in GitHub Desktop.
plot.CRD.layout function: the function for generate completely radomized design
library(agricolae)
library(desplot)
plot.CRD.layout <- function(trt_name, num_rep){
repeticion <- rep(num_rep, length(trt))
CRD <- design.crd(trt, r = repeticion, serie = 0)
CRD_layout <- CRD$book
CRD_layout$block <- "B1"
CRD_layout$x <- rep(1:num_rep, each = length(trt_name))
CRD_layout$y <- rep(1:length(trt), num_rep)
CRD_layout$trt <- sample(as.character(as.factor(CRD_layout$trt_name)))
plot_crd <- desplot(data = CRD_layout, block ~ x + y, text = trt, show.key = FALSE, cex = 2)
plot(plot_crd)
}
# example
# plot.CRD.layout(trt_name = c("A", "B"), num_rep = 3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment