[R] Questions about bwplot

Richard M. Heiberger rmh at temple.edu
Mon May 21 16:07:47 CEST 2007


## I simplified this panel function by taking the calculations outside
## the panel function to allow use of the original variable names.


my.boxpanel3  <-  function(x, y, subscripts, ..., medians, best) { 
  cols <- grey(1-best[,panel.number()]/3)
  panel.bwplot(x, y, fill=cols, ...) 
  panel.abline(h=medians[panel.number()])
}   

td3 <- test.data[test.data$Alg != "R1",]
td3$Alg <- factor(td3$Alg)
levels(td3$Alg)


R1.medians <- with(test.data[test.data$Alg=="R1",], tapply(Value, GOF, median))
A.best <- with(td3, tapply(Value, data.frame(Alg, GOF), median))
A.min <- apply(A.best, 2, function(x) x==min(x))
A.max <- apply(A.best, 2, function(x) x==max(x))
A.best <- cbind(A.min[ ,1:2, drop=FALSE], A.max[ ,3, drop=FALSE])


bwplot(Value ~ Alg | GOF, data = td3, scale=list(relation="free"), 
       as.table=T, layout=c(1,3), panel=my.boxpanel3,
       ylim=list(c(0,1), c(-2,2), c(0,17)),
       medians=R1.medians,
       best=A.best)



More information about the R-help mailing list