Hi:

On Fri, Jul 2, 2010 at 8:57 AM, Rajarshi Guha <rajarshi.guha@gmail.com>wrote:

> Hi, I have a lattice lot conditioned on two variables. Example code is:
>
> library(lattice)
> x <- data.frame(d=runif(100),
>                f1=sample(c('yes', 'no'),100,replace=TRUE),
>                f2=c(rep('Run1',30),rep('Run2',30),rep('Run3',40)))
> histogram(~d | f1 + f2, x)
>
> In the plot, for a given value of f2, there are two panels, one for
> 'n' and one for 'yes'. But above each panel I get the value of f2.
>
> What I'd like to be able to do is to have the value of f2 span the two
> panels (ie merge the green rows and use a single label).
>

One alternative to Peter's suggestion is to use the strip.combined()
function in the
Lattice book (p. 197) which merges the two strip labels into one:

strip.combined <- function(which.given, which.panel, factor.levels, ...) {
  if (which.given == 1) {
      panel.rect(0, 0, 1, 1, col = "grey90", border = 1)
      panel.text(x = 0, y = 0.5, pos = 4, lab =
factor.levels[which.panel[which.given]])
                        }
  if (which.given == 2) {
      panel.text(x = 1, y = 0.5, pos = 2, lab =
factor.levels[which.panel[which.given]])
                        } }

and then call the histogram function as follows:

histogram(~ d | f1 + f2, data = x, strip = strip.combined)
or
histogram(~ d | f1 + f2, data = x, strip = strip.combined, as.table = TRUE)

if you prefer the Run* values to go from top to bottom instead.

If you'd prefer a different layout for the strip labels but of this general
form,
you could write your own panel function modeled on the strip.combined()
function given above.


HTH,
Dennis

Any pointers as to how I could acheive this would be appreciated
>
> Thanks,
>
> --
> Rajarshi Guha
> NIH Chemical Genomics Center
>
> ______________________________________________
> R-help@r-project.org 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.
>

	[[alternative HTML version deleted]]

