Skip to content
Prev 267476 / 398502 Next

lattice: index plot

On 2011-08-03 00:24, Thaler,Thorn,LAUSANNE,Applied Mathematics wrote:
Here's a way to use 'subscripts' in the xyplot.
The main problem is to determine the xlims to use.

  dat <- data.frame(y, grp)

  ## xlims
  xL <- function(groups){
    tbl <- table(groups)
    xlim <- c(0, max(tbl) + 1)
    xlim
  }

  xyplot(y ~ seq_along(y) | factor(grp), data = dat,
    xlim = xL(dat$grp),
    panel = function(y, subscripts){
      x <- seq_along(subscripts)
      panel.xyplot(x, y)
    }
  )


Peter Ehlers