library(agridat)
data(kayad.alfalfa)
dat <- kayad.alfalfa
# match Kayad table 1 stats
libs(dplyr)
dat <- group_by(dat, harvest)
summarize(dat, min=min(yield), max=max(yield),
mean=mean(yield), stdev=sd(yield), var=var(yield))
# Figure 4 of Kayad
libs(latticeExtra)
catcols <- c("#cccccc","#ff0000","#ffff00","#55ff00","#0070ff","#c500ff","#73004c")
levelplot(yield ~ long*lat |harvest, dat,
aspect=1, at = c(0,2,3,4,5,6,7,10), col.regions=catcols,
main="kayad.alfalfa",
prepanel=prepanel.default.xyplot,
panel=panel.levelplot.points)
# Similar to Kayad fig 5.
## levelplot(yield ~ long*lat |harvest, dat,
## prepanel=prepanel.default.xyplot,
## panel=panel.levelplot.points,
## col.regions=pals::brewer.reds)
Run the code above in your browser using DataLab