This short note shows how to plot a field map from an agricultural experiment and why that may be useful.
library("knitr")
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)
library(desplot)
data(yates.oats)
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.2.5 (2016-04-14)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 7 x64 (build 7601) Service Pack 1
##
## locale:
## [1] LC_COLLATE=English_United States.1252 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] grid stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] mapproj_1.2-4 maps_3.1.0 HH_3.1-31 gridExtra_2.2.1
## [5] multcomp_1.4-4 TH.data_1.0-7 MASS_7.3-45 survival_2.39-2
## [9] mvtnorm_1.0-5 latticeExtra_0.6-28 RColorBrewer_1.1-2 gge_1.0
## [13] agridat_1.13 lme4_1.1-12 Matrix_1.2-5 nlme_3.1-127
## [17] knitr_1.12.3 rmarkdown_0.9.5 BlandAltmanLeh_0.3.1 dplyr_0.4.3
## [21] LaunchR_1.0.8.0 kw_1.64 desplot_1.00 lattice_0.20-33
## [25] reshape2_1.4.1 rio_0.3.10 lucid_1.4 R2jags_0.5-7
## [29] rjags_4-6 R2WinBUGS_2.1-21 boot_1.3-18 coda_0.18-1
## [33] devtools_1.11.0
##
## loaded via a namespace (and not attached):
## [1] Biobase_2.28.0 jsonlite_0.9.19 splines_3.2.5 Formula_1.2-1
## [5] shiny_0.13.2 assertthat_0.1 urltools_1.4.0 cellranger_1.0.0
## [9] yaml_2.1.13 readODS_1.6.2 chron_2.3-47 digest_0.6.9
## [13] minqa_1.2.4 colorspace_1.2-6 sandwich_2.3-4 htmltools_0.3.5
## [17] httpuv_1.3.3 plyr_1.8.3 XML_3.98-1.4 haven_0.2.0
## [21] xtable_1.8-2 scales_0.4.0 openxlsx_3.0.0 gmp_0.5-12
## [25] ggplot2_2.1.0 withr_1.0.1 nnet_7.3-12 BiocGenerics_0.14.0
## [29] lazyeval_0.1.10 Rmpfr_0.6-0 mime_0.4 magrittr_1.5
## [33] readxl_0.1.1 memoise_1.0.0 evaluate_0.8.3 xml2_0.1.2
## [37] foreign_0.8-66 tools_3.2.5 data.table_1.9.6 formatR_1.3
## [41] stringr_1.0.0 munsell_0.4.3 cluster_2.0.4 pcaMethods_1.58.0
## [45] compiler_3.2.5 vcd_1.4-1 nloptr_1.0.4 leaps_2.9
## [49] tcltk_3.2.5 gtable_0.2.0 codetools_0.2-14 abind_1.4-3
## [53] DBI_0.3.1 curl_0.9.7 R6_2.1.2 zoo_1.7-12
## [57] Hmisc_3.17-3 readr_0.2.2 stringi_1.0-1 parallel_3.2.5
## [61] Rcpp_0.12.4 rpart_4.1-10 acepack_1.3-3.3 gclus_1.3.1
## [65] lmtest_0.9-34
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.