Re: [R] Direction of panel plots in trellis graphics

From: <deepayan.sarkar_at_gmail.com>
Date: Fri, 13 Jul 2007 09:11:23 -0700

On 7/13/07, Richard M. Heiberger <rmh_at_temple.edu> wrote:
> You can control the panel sequence with subscripting and transpose.
> Here are several examples. I think tmp.tr3 is the one you asked for.
>
> library(lattice)
>
> tmp <- data.frame(x=rnorm(24), y=rnorm(24), a=rep(letters[1:6],4),
> b=rep(LETTERS[1:4],each=6))
> tmp.tr <- xyplot(y ~ x | a*b, data=tmp)
> tmp.tr
> t(tmp.tr)
>
> tmp.tr2 <- xyplot(y ~ x | a, data=tmp)
> tmp.tr2
> tmp.tr2[c(1,3,5,2,4,6)]
>
> tmp.tr3 <- xyplot(y ~ x | a, data=tmp, as.table=TRUE)
> tmp.tr3
> tmp.tr3[c(1,3,5,2,4,6)]

Another high level option is to change the rule determining how packets are chosen for a given panel in the layout.

print(tmp.tr3,

      packet.panel = function(layout, row, column, ...) {
          layout <- layout[c(2, 1, 3)]
          packet.panel.default(layout = layout,
                               row = column,
                               column = row, ...)
      })

This effectively transposes the layout, which (along with as.table=TRUE) is what you want.

-Deepayan



R-help_at_stat.math.ethz.ch 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. Received on Fri 13 Jul 2007 - 16:44:41 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 13 Jul 2007 - 19:33:02 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.