[R] Direction of panel plots in trellis graphics

2007-07-13 Thread Yan Wong
Hi,

Using library(lattice), is there any way to tell xyplot to plot  
panels top to bottom, then left to right (i.e. panels are appended  
vertically, then horizontally). as.table changes the plot direction  
from left-to-right then top-to-bottom, to right-to-left then bottom- 
to-top, but that's not quite what I want to do.

Thanks

Yan

__
R-help@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.


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

2007-07-13 Thread Richard M. Heiberger
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)]
 
Rich

__
R-help@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.


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

2007-07-13 Thread Gabor Grothendieck
See this:

http://tolstoy.newcastle.edu.au/R/help/06/08/32543.html

and also the other messages in that thread.

On 7/13/07, Yan Wong <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Using library(lattice), is there any way to tell xyplot to plot
> panels top to bottom, then left to right (i.e. panels are appended
> vertically, then horizontally). as.table changes the plot direction
> from left-to-right then top-to-bottom, to right-to-left then bottom-
> to-top, but that's not quite what I want to do.
>
> Thanks
>
> Yan
>
> __
> R-help@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.
>

__
R-help@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.


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

2007-07-13 Thread deepayan . sarkar
On 7/13/07, Richard M. Heiberger <[EMAIL PROTECTED]> 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@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.


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

2007-07-13 Thread Yan Wong

On 13 Jul 2007, at 17:11, [EMAIL PROTECTED] wrote:

>
> 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.

Thank you Deepayan, that does exactly what I want.

Also thanks for the other suggestions by Gabor and Richard.  
Unfortunately these don't quite work in my case, as I am printing to  
multiple pages (so Richard's suggestion of transposing becomes  
tricky), and my 2 conditioning variables are on the rhs and lhs of  
the formula (i.e. y1 + y2 = x | v) (so I can't easily create a new  
combination factor as in Gabor's situation).

Cheers

Yan

__
R-help@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.