Skip to content

More help with Lattice

4 messages · Jean-Pierre Gattuso, Deepayan Sarkar, ken_lee +1 more

#
Hi:

Thanks a lot to Deepayan Sarkar, author of lattice I think, who 
solved my first query. I am afraid that I have another one.

I am plotting several mutipanels boxplots (with one conditioning 
variable) on one page. The x, y and conditioning variable are all 
continuous variables. The x and conditioning variables are 
transformed to shingles before being plotted. The plot looks nice but 
there are two changes that I cannot manage to do.

1- The labels displayed on the y axis are of course the categories of 
the shingle. I would like to display instead the actual intervals of 
the shingle. Is that possible?

2- It is even worse for the conditioning variable because its name is 
displayed, with no information on the interval that it represents in 
each panel (except the colored rectangle that moves along the strip). 
Anyway, I got rid of the strip because vertical space is at premium 
on this page. Here too, I would like to display the interval of the 
conditioning variable on each panel. Andrew C. Ward suggested that I 
should use ltext in a panel function but I did not succeed.

What is the documentation available for lattice? I have "Tour of 
Trellis" (Becker et al.) and the S user's manual on Treillis. These 
documents, together with the help pages, got me quite a long way. 
However, some instructions are not very clear (at least for a newbie, 
with no programming expertise), especially for the use of panel 
functions. Is there any other documentation available? I know, I 
could have gone the R-help archives but I am out of the office and 
rely on a slow and rather unreliable Internet connection.

I am sorry to have produced such a long msg.

Thanks in advance for your help.
jp
#
--- Jean-Pierre Gattuso <gattuso at obs-vlfr.fr> wrote:
This one's easy. For example, 

x <- rnorm(100)
y <- equal.count(rnorm(100))
z <- equal.count(rnorm(100))

ylabels <- substring(as.character(levels(y)), 2)
## or,  if these are too long
## ylabels <- substring(as.character(lapply(levels(y), round, 3)), 2)

bwplot(y ~ x | z, scales = list(y = list(labels = ylabels)))
This might be a problem if you don't want to use the strip function, since a
panel function is usually not sent any information about which levels of the
conditioning variable it corresponds to. With strip, it should be easy:

zlabels <- substring(as.character(levels(z)), 2)
bwplot(y ~ x | z, strip = function(which.given, ...)    
       grid.text(zlabels[which.given]))
## assuming that you have only one conditioning variable
Currently, there's not much else. (Incidentally, everything I used is
documented in the help pages, although they might be a bit difficult to find.)
A web page is in the making (at packages.r-project.org/lattice), but I haven't
gotten around to really starting it up yet.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


__________________________________________________



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Dear,
       I thought these two example are bugs. 
example 1:  colnames issue
 > tmp<-data.frame(value=1:3,group1=1:3)     
 > if (length(tmp$group)>1) z<-1 else z<-2
 > print(z)

   [1] 1

example2 :  length issue
value group
a     2     a
b     1     b
value group
a     1     a
b     3     b
c     2     c

ken
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
"ken_lee" <ken_lee at tynesys.com> writes:
tmp$group is 1:3 because of partial matching in "$" (which is not a
bug, but maybe a design infelicity).
That's how gsummary (from nlme) works. Look at the definition of FUN.