Re: [R] Adding per-panel text to panel strips in lattice xyplot

2006-10-17 Thread Deepayan Sarkar
On 10/13/06, Frank E Harrell Jr [EMAIL PROTECTED] wrote:
 I would like to add auxiliary information to the bottom of two strips on
 each panel that comes from a table look-up using the values of two
 variables that define the panel.  For example I might panel on sex and
 race, showing 3 randomly chosen time series in each panel and want to
 add (n=100) in the bottom strip to indicate the 3 curves were sampled
 from 100.  Is there a not-too-hard way to do that?

 I would like to do this both with and without groups= and superposition,
 but especially with.

There might be, but it might be easier with some changes to lattice.
Can you give a minimal example so that we can try out ideas?

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] Adding per-panel text to panel strips in lattice xyplot

2006-10-17 Thread Frank E Harrell Jr
Deepayan Sarkar wrote:
 On 10/13/06, Frank E Harrell Jr [EMAIL PROTECTED] wrote:
 I would like to add auxiliary information to the bottom of two strips on
 each panel that comes from a table look-up using the values of two
 variables that define the panel.  For example I might panel on sex and
 race, showing 3 randomly chosen time series in each panel and want to
 add (n=100) in the bottom strip to indicate the 3 curves were sampled
 from 100.  Is there a not-too-hard way to do that?

 I would like to do this both with and without groups= and superposition,
 but especially with.
 
 There might be, but it might be easier with some changes to lattice.
 Can you give a minimal example so that we can try out ideas?
 
 Deepayan
 

Thanks for your note Deepayan.  The difficulty is that the quantity to 
add may need to be obtained by a table look-up given current panel strip 
values.  I have gotten around this by duplicating the lookup values 
(here sizecluster) to correspond to x and y then using subscripts.  The 
code snippet below does not put the extra value in a strip but right 
under the bottom strip.  Better would be inside the bottom strip.

 textfun - function(subscripts) {
   if(!length(subscripts)) return()
   size - sizecluster[subscripts[1]]
   txt - paste('N=',size,sep='')
   grid.text(txt, x=.005, y=.99, just=c(0,1),
 gp=gpar(fontsize=9, col=gray(.25)))
 }

xyplot(Y ~ X | distribution*cluster, groups=curve,
  xlab=xlab, ylab=ylab,
  xlim=xlim, ylim=ylim,
  as.table=TRUE,
  panel=function(x, y, subscripts, ...) {
 panel.superpose(x, y, subscripts, ...)
 textfun(subscripts)
   })

Thanks
-- 
Frank E Harrell Jr   Professor and Chair   School of Medicine
  Department of Biostatistics   Vanderbilt University

__
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] Adding per-panel text to panel strips in lattice xyplot

2006-10-17 Thread Deepayan Sarkar
On 10/17/06, Frank E Harrell Jr [EMAIL PROTECTED] wrote:
 Deepayan Sarkar wrote:
  On 10/13/06, Frank E Harrell Jr [EMAIL PROTECTED] wrote:
  I would like to add auxiliary information to the bottom of two strips on
  each panel that comes from a table look-up using the values of two
  variables that define the panel.  For example I might panel on sex and
  race, showing 3 randomly chosen time series in each panel and want to
  add (n=100) in the bottom strip to indicate the 3 curves were sampled
  from 100.  Is there a not-too-hard way to do that?
 
  I would like to do this both with and without groups= and superposition,
  but especially with.
 
  There might be, but it might be easier with some changes to lattice.
  Can you give a minimal example so that we can try out ideas?
 
  Deepayan
 

 Thanks for your note Deepayan.  The difficulty is that the quantity to
 add may need to be obtained by a table look-up given current panel strip
 values.  I have gotten around this by duplicating the lookup values
 (here sizecluster) to correspond to x and y then using subscripts.  The
 code snippet below does not put the extra value in a strip but right
 under the bottom strip.  Better would be inside the bottom strip.

  textfun - function(subscripts) {
if(!length(subscripts)) return()
size - sizecluster[subscripts[1]]
txt - paste('N=',size,sep='')
grid.text(txt, x=.005, y=.99, just=c(0,1),
  gp=gpar(fontsize=9, col=gray(.25)))
  }

 xyplot(Y ~ X | distribution*cluster, groups=curve,
   xlab=xlab, ylab=ylab,
   xlim=xlim, ylim=ylim,
   as.table=TRUE,
   panel=function(x, y, subscripts, ...) {
  panel.superpose(x, y, subscripts, ...)
  textfun(subscripts)
})

Well, the strip function has always been passed an argument called
'which.panel' (and the latest lattice has a function called
'which.packet()' which gives the same information inside a panel
function as well). It seems to me that that's the thing you want to
use. E.g.

 library(lattice)
 dotplot(variety ~ yield | site * year, data = barley,
+ strip = function(..., which.panel) print(which.panel))
[1] 1 1
[1] 1 1
[1] 2 1
...
[1] 5 2
[1] 6 2
[1] 6 2

-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] Adding per-panel text to panel strips in lattice xyplot

2006-10-17 Thread Richard M. Heiberger
This looks like an application for bottom.strips and right.strips,
in addition to the current left.strips and strips, in each panel.
The new feature is that these new strips might be associated with
different information than the regular strips that reflect
the levels of the conditioning variables.

__
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] Adding per-panel text to panel strips in lattice xyplot

2006-10-13 Thread Frank E Harrell Jr
I would like to add auxiliary information to the bottom of two strips on 
each panel that comes from a table look-up using the values of two 
variables that define the panel.  For example I might panel on sex and 
race, showing 3 randomly chosen time series in each panel and want to 
add (n=100) in the bottom strip to indicate the 3 curves were sampled 
from 100.  Is there a not-too-hard way to do that?

I would like to do this both with and without groups= and superposition, 
but especially with.

Thanks
Frank
-- 
Frank E Harrell Jr   Professor and Chair   School of Medicine
  Department of Biostatistics   Vanderbilt University

__
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] Adding per-panel text to panel strips in lattice xyplot

2006-10-13 Thread Richard M. Heiberger
Take a look at the xysplom function in package HH.
You can use it as a model for what you want.

tmp - data.frame(x=rnorm(24),
  y=rnorm(24),
  a=factor(rep(letters[1:2],12)),
  b=factor(rep(LETTERS[1:3], c(8,8,8
xysplom(y ~ x | a*b, data=tmp, corr=TRUE, layout=c(2,3))
 
The work is done with the cooperation of two functions.

xysplom.default looks for the corr argument and then creates
an additional conditioning factor and gives it a constant value.

strip.xysplom sees where it is and changes the strip label as needed.

strip.xysplom uses the R-2.3.1 technology for finding where it is.
Deepayan added some more functions in R-2.4.1, so that part of
the code can now be somewhat simplified.

lattice in R-2.4.0 also has a new strip.left argument (see ?xyplot and
serach for strip.left) that will allow you to put the additional
information in an additional left strip for each panel, rather than by making
changes to one of the standard top strips.

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.