Learn R Programming

agridat (version 1.5)

desplot: Plot the layout/data of a field experiment

Description

Plot the layout/data of a field experiment

Usage

desplot(form=formula(NULL ~ x + y), data,
  num, col, text, out1, out2,
  col.regions=RedGrayBlue, col.text=NULL, text.levels=NULL, 
  out1.gpar=gpar(col = "black", lwd = 3),
  out2.gpar=gpar(col = "yellow", lwd = 1, lty = 1),
  at, ticks=FALSE, flip=FALSE, main, xlab, ylab,
  shorten="abb", show.key=TRUE, key.cex, cex=0.4, strip.cex=0.75, ...)

Arguments

form
A formula like yield~x*y|location
data
A data frame
num
The column of the data to use for plotting numbers
col
Column of the data for the color of the number
text
Column to use for text labels
out1
Column to use for outlining
out2
Column to use for outlining
col.regions
Colors for regions
col.text
Colors for text strings
text.levels
Character strings to use instead of default 'levels'
out1.gpar
Graphics parameters for outlining
out2.gpar
Graphics parameters for outlining
at
Breakpoints for the color ribbon
ticks
If TRUE, show tick marks row/column
flip
If TRUE, vertically flip the image
main
Main title
xlab
Label for x axis
ylab
Label for y axis
shorten
Method for shortening text in the key
show.key
If TRUE, show the key
cex
Expansion factor for text/number in each cell
key.cex
Left legend cex
strip.cex
Strip cex
...
Other

Details

Ryder (1981) discusses the need to examine the layout of the experiment design, and not just the data. This function provides a a tool for plotting the layout of a field experiment and also the observed data. Not all parameters are passed down to xyplot. One way around this is assign the desplot object to a variable, then use update to modify the plot, and then print it. Use col.regions to specify fill colors. This can either be a vector of colors or a function that produces a vector of colors. If the response variable is a factor and col.regions is a function, it will be ignored and the cells are filled with default light-colored backgrounds and a key is placed on the left. If the response variable is numeric, the cells are colored according to col.regions, and a ribbon key is placed on the right. The default shorten='abb' will shorten the cell text using the abbreviate function. Other choices include shorten='sub' to use a 3-character substring, and shorten='no' for no shortening. Note that two sub-plots with identical levels of the split-plot factor can be adjacent to each other by virtue of appearing in different whole-plots. To correctly outline the split-plot factor, simply concatenate the whole-plot factor and sub-plot factor together.

References

K. Ryder (1981). Field plans: why the biometrician finds them useful, Experimental Agriculture, 17, 243--256.

Examples

Run this code
data("Wheat2", package="nlme")
# Convert lat/long to integers
Wheat2$y <- as.numeric(as.factor(Wheat2$latitude))
Wheat2$x <- as.numeric(as.factor(Wheat2$longitude))
desplot(yield ~ x*y, data=Wheat2, out1=Block, aspect=2)

desplot(Block ~ x*y, data=Wheat2, num=variety, out1=Block)

desplot(yield ~ x+y, yates.oats, out1=block, out2=gen)

desplot(gen ~ x+y, yates.oats, col=block, num=nitro, cex=1,
out1=block)

desplot(block ~ x+y, yates.oats, col=nitro, text=gen, cex=1, out1=block)

# Example from Ryder.
gnut <- ryder.groundnut
m1 <- lm(dry~block+gen, gnut)
gnut$res <- resid(m1)
# Note largest positive/negative residuals are adjacent
desplot(res ~ col + row, gnut, text=gen, cex=1)

Run the code above in your browser using DataLab