Hi Deepayan,

Deepayan Sarkar <[EMAIL PROTECTED]> 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

Reply via email to