In the orchard experiment, there are 5 treatments and 5 blocks. To allow for analysis of the effects of the treatments on tree and fruit growth the treatments are the same on either side of the middle tree row. How can I randomise the treatments in R without having the last treatment of a block being the same as the starting treatment of the next block. For example, I have used the agricolae package to randomise the treatments within their blocks but I get randomisation such as this:
Block 1: 3 1 5 2 4
Block 2: 2 3 4 5 1
Block 3: 2 5 1 4 3
Block 4: 1 5 3 4 2
Block 5: 2 3 1 5 4
As you can see block 4 finishes with treatment 2 and then block 5 starts with 2. I would like to avoid this if possible but I am not sure how to do it in r.
A visual representation of the experiment with the treatments not randomised within their plots:
Running the solution below, I come across the issue of the new table not showing numbers.
Imagine you had data that looked like this:
You could use a
while
loop to continue resampling by group until none of the block boundaries equaled each other:Note that
cumsum
withrle
allows us to return the indices of boundaries between blocks.head(x,-1)
removes the last one because we don't care about it:Sample Data: