I am trying to plot randomization layout in R/ graphics.
Trt <- c(paste ("Trt#", 1:10, sep = ""))
mydes <- data.frame (block1= sample(Trt), block2 = sample(Trt), block3= sample(Trt), block4= sample( Trt), block5= sample(Trt))
plot(c(0, NCOL(mydes)), c(0, NROW(mydes)), type= "n", xlab="blocks", ylab = "range")
grid(lty = 2, col = 1)
mydes
block1 block2 block3 block4 block5
1 Trt#10 Trt#5 Trt#4 Trt#6 Trt#8
2 Trt#6 Trt#8 Trt#9 Trt#2 Trt#3
3 Trt#3 Trt#6 Trt#5 Trt#10 Trt#9
4 Trt#9 Trt#4 Trt#1 Trt#5 Trt#2
5 Trt#5 Trt#9 Trt#7 Trt#3 Trt#5
6 Trt#7 Trt#3 Trt#3 Trt#7 Trt#7
7 Trt#8 Trt#10 Trt#8 Trt#4 Trt#4
8 Trt#1 Trt#7 Trt#10 Trt#9 Trt#1
9 Trt#4 Trt#1 Trt#2 Trt#1 Trt#10
10 Trt#2 Trt#2 Trt#6 Trt#8 Trt#6
I want to add the text in middle of each grid rectangle. I know I can do it painfully by adding text and specifying coordinates one by one. But I want a generalized solution with some short of loop, that can be applied to any other dimensions as well.
Thanks;
Here is a way of doing it in
ggplot:Since you want to plot this, rather than just printing a table, you may as well use a colour scale to map treatments with the same value: