This short note shows how to plot a field map from an agricultural experiment and why that may be useful.
library("knitr")
## Warning: package 'knitr' was built under R version 3.3.2
knitr::opts_chunk$set(fig.align="center", fig.width=6, fig.height=6)
options(width=90)
First, a plot of the experimental design of the oats data from Yates (1935).
library(agridat)
## Warning: package 'agridat' was built under R version 3.3.2
library(desplot)
##
## Attaching package: 'desplot'
## The following objects are masked from 'package:agridat':
##
## RedGrayBlue, desplot
data(yates.oats)
# Older versions of agridat used x/y here instead of col/row
if(is.element("x",names(yates.oats)))
yates.oats <- transform(yates.oats, col=x, row=y)
desplot(block ~ col+row, yates.oats,
col=nitro, text=gen, cex=1, out1=block,
out2=gen, out2.gpar=list(col = "gray50", lwd = 1, lty = 1))
This next example is from Ryder (1981). Fit an ordinary RCB model with fixed effects for block
and genotype
. Plot a heatmap of the residuals.
library(agridat)
library(desplot)
data(ryder.groundnut)
gnut <- ryder.groundnut
m1 <- lm(dry ~ block + gen, gnut) # Standard RCB model
gnut$res <- resid(m1)
desplot(res ~ col + row, gnut, text=gen, cex=1,
main="ryder.groundnut residuals from RCB model")
Note the largest positive/negative residuals are adjacent to each other, perhaps caused by the original data values being swapped. Checking with experiment investigators (managers, data collectors, etc.) is recommended.
sessionInfo()
## R version 3.3.1 (2016-06-21)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 7 x64 (build 7601) Service Pack 1
##
## locale:
## [1] LC_COLLATE=C LC_CTYPE=English_United States.1252
## [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
## [5] LC_TIME=English_United States.1252
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] desplot_1.1 agridat_1.12 knitr_1.15.1
##
## loaded via a namespace (and not attached):
## [1] Rcpp_0.12.8 lattice_0.20-34 digest_0.6.10 rprojroot_1.1 grid_3.3.1
## [6] plyr_1.8.4 backports_1.0.4 magrittr_1.5 evaluate_0.10 stringi_1.1.2
## [11] reshape2_1.4.2 rmarkdown_1.2 tools_3.3.1 stringr_1.1.0 yaml_2.1.14
## [16] htmltools_0.3.5
Ryder, K. 1981. “Field Plans: Why the Biometrician Finds Them Useful.” Experimental Agriculture 17: 243–56. doi:10.1017/S0014479700011601.
Yates, Frank. 1935. “Complex Experiments.” Journal of the Royal Statistical Society Suppl 2: 181–247. doi:10.2307/2983638.