Dear R users,

I have a function I created to generate randomized block designs given 
below. Once  I generate the design, I would like to plot it in a 
rectangular form to mimic the excel style where the blocks are 
represented with the treatment values placed exactly where their 
appropriate X and Y coordinates are.

## A function to generate a RCB design

rcbd<-function(b,g,rb,cb,r,c)
{
   # b =number of blocks
   # g = a vector of treatments
   # rb = number of rows per blocks
   # cb =number of columns per block
   # r = total rows
   # c = total columns
library(foreach)
genotypes<-times(b) %do% sample(g,length(g))
block<-rep(1:b,each=length(g))
genotypes<-factor(genotypes)
block<-factor(block)
### generate the base design
k<-c/cb # number of blocks on the x-axis
x<-rep(rep(1:r,each=cb),k)  # X-coordinate
l<-cb
p<-r/rb
m<-l+1
d<-l*b/p
y<-c(rep(1:l,r),rep(m:d,r)) # Y-coordinate
data.frame(x,y,block,genotypes)
}
set.seed(100)
rcbd(b=4,g=1:4,rb=2,cb=2,r=4,c=4)

    x y block genotypes
1  1 1     1         2
2  1 2     1         1
3  2 1     1         4
4  2 2     1         3
5  3 1     2         2
6  3 2     2         4
7  4 1     2         3
8  4 2     2         1
9  1 3     3         3
10 1 4     3         1
11 2 3     3         2
12 2 4     3         4
13 3 3     4         2
14 3 4     4         4
15 4 3     4         3
16 4 4     4         1

How can I produce a diagram like this one below or a better one for any run of 
my function?


2       4       2       3
1       3       4       1
3       2       2       3
1       4       4       1


Regards,
Laz





        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to