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

From: Deepayan Sarkar <deepayan.sarkar_at_gmail.com>
Date: Fri 23 Sep 2005 - 08:44:50 EST

On 9/22/05, Sebastian Luque <spluque@gmail.com> wrote:
> 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):

This might be a better approach then:

bwplot(grp ~ age | sex, aspect = 0.5, box.ratio = 2,

       scales = list(y = "free", rot = 0),
       prepanel = function(x, y, ...) {
           tg <- table(y);
           list(ylim = paste(names(tg), "(", tg, ")"))
} )

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 Received on Fri Sep 23 08:55:04 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 17:40:18 EST