Skip to content
Prev 99143 / 398498 Next

lattice and several groups

Try this version which corresponds to your latest version
but makes use of panel.groups distinguishing the groups
using group.number:

# set custom col and pch here
my.col <- 1:nlevels(df$f2)
my.pch <- 1:nlevels(df$f1)

pnl <- function(x, y, subscripts, pch, group.number, ...) {
  panel <- c(panel.lmline, panel.loess, panel.loess)[[group.number]]
  panel(x, y, ..., pch = pch[subscripts])
  panel.xyplot(x, y, pch = my.pch[df[subscripts, "f1"]], ...)
}


xyplot(y ~ x | surveys, data = df, groups = df$f2, type = "b",
       panel = panel.superpose,
       panel.groups = pnl,
       par.settings = list(superpose.line = list(col = my.col),
          superpose.symbol = list(col = my.col))

)


key1 <- list(border = TRUE, colums = 2, text = list(levels(df$f1)),
      points = list(pch = my.pch)

)

key2 <- list(border = TRUE, colums = 2, text = list(levels(df$f2)),
      lines = list(col = my.col)
)

draw.key(key1, draw = TRUE, vp = viewport(.9, .9))
draw.key(key2, draw = TRUE, vp = viewport(.75, .9))
On 9/3/06, Laurent Rhelp <laurentRhelp at free.fr> wrote: