[R] add custom strip to lattice plot

Patrick Drechsler patrick at pdrechsler.de
Mon Jul 30 23:24:49 CEST 2007


Hi,

what is the recommended way of adding a strip to a lattice plot?

In the example below I would like to add the value of mean(y) to a new
strip.:

--8<---------------cut here---------------start------------->8---
library(lattice)

## Small sample data set:
p0 <- xyplot(uptake ~ Type | Treatment, data = CO2)

p1 <- update(p0,
             panel = function(x, y, ...) {
               panel.xyplot(x, y)
               panel.abline(h = mean(y),
                            col = "red"
                            )
             }
             )

plot(p1)
--8<---------------cut here---------------end--------------->8---

TIA

Patrick



More information about the R-help mailing list