if (FALSE) {
library(agridat)
data(lin.superiority)
dat <- lin.superiority
libs(latticeExtra)
libs(reshape2)
# calculate the superiority measure of Lin & Binns 1988
dat2 <- acast(dat, gen ~ loc, value.var="yield")
locmean <- apply(dat2, 2, mean)
locmax <- apply(dat2, 2, max)
P <- apply(dat2, 1, function(x) {
sum((x-locmax)^2)/(2*length(x))
})/1000
P <- sort(P)
round(P) # match Lin & Binns 1988 table 2, column Pi
# atlantic & quebec regions overlap
# libs(gge)
# m1 <- gge(dat, yield ~ gen*loc, env.group=region,
# main="lin.superiority")
# biplot(m1)
# create a figure similar to Lin & Binns 1988
# add P, locmean, locmax back into the data
dat$locmean <- locmean[match(dat$loc, names(locmean))]
dat$locmax <- locmax[match(dat$loc, names(locmax))]
dat$P <- P[match(dat$gen, names(P))]
dat$gen <- reorder(dat$gen, dat$P)
xyplot(locmax ~ locmean|gen, data=dat,
type=c('p','r'), as.table=TRUE, col="gray",
main="lin.superiority - Superiority index",
xlab="Location Mean",
ylab="Yield of single cultivars (blue) & Maximum (gray)") +
xyplot(yield ~ locmean|gen, data=dat,
type=c('p','r'), as.table=TRUE, pch=19)
}
Run the code above in your browser using DataLab