Hi Deepayan Many thanks for bringing the which.packet() function to my attention--I missed it in the book. I do prefer that the panel function applies the labels to the data rather than adding them directly to the data in advance.
Jeff On Tue, Apr 12, 2011 at 8:50 AM, Deepayan Sarkar <deepayan.sar...@gmail.com> wrote: > On Mon, Apr 11, 2011 at 12:49 AM, Jeff Stevens <stev0...@gmail.com> wrote: >> Many thanks, Peter. This works brilliantly, and I prefer to have the >> labels assigned outside of panel function as well. > > You could also consider using which.packet(). You haven't explicitly > told us how the labels are matched with the boxplots, but assuming > that the labels are in the order of plotting, you can do [using the > original data]: > > > df <- data.frame(f1, f2, dv) > lab <- c(1, 2, 3, 4, 5, 6) > > bwplot(dv ~ f1 | f2, data = df, ylim = c(0.5, 1), > text.labels = as.character(lab), > panel = function(x, y, ..., text.labels) { > panel.bwplot(x, y, ...) > n <- nlevels(x) > i <- seq_len(n) + (which.packet() - 1) * n > print(text.labels[i]) > panel.text(x = seq_len(n), y = 0.55, > labels = text.labels[i]) > }) > > -Deepayan > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.