Re: [R] annotating an axis in bwplot (lattice)

From: Sebastian Luque <spluque_at_gmail.com>
Date: Fri 23 Sep 2005 - 08:03:37 EST

Hi Deepayan,

Deepayan Sarkar <deepayan.sarkar@gmail.com> wrote:

[...]

> If you really want the frequencies for the whole (subsetted) data, you
> might as well use something like:

> dd <- data.frame(age, sex, grp)

> with(subset(dd, age > 20),
> bwplot(grp ~ age | sex, aspect = 0.5, box.ratio = 2,
> ylim = {
> tg <- table(grp)
> paste(names(tg), "(", tg, ")")
> }))

Thanks, this is almost what I was looking for. Because I needed the frequency of each group in *each* panel, I modified your suggestion like (omitting the panel function for briefness):

--8<---------------cut here---------------start------------->8--- with(subset(dd, age > 20),

     bwplot(grp ~ age | sex, aspect = 0.5, box.ratio = 2,
            scales = list( y = list(relation = "free")),
	    ylim = {
	      tgf <- table(grp[sex == "Female"])
              tgm <- table(grp[sex == "Male"])
              list(paste(names(tgf), "(", tgf, ")"),
                   paste(names(tgm), "(", tgm, ")"))
            }))

--8<---------------cut here---------------end--------------->8---

One has to be careful though with the order of panels.

Thank you,

-- 
Sebastian P. Luque

______________________________________________
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
Received on Fri Sep 23 08:16:03 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:40:25 EST