Dear R-users,

I am using R version 2.9.1 and lattice 0.17-26 under windows.
In a lattice boxplot, I would like to add information on how many observations 
each singel boxplot is based upon.

For example (the basic plot):
# Begin R-code
library(lattice)
dat <- data.frame(panvar = rep(c("A","B","A","B"), c(3,7,4,6)), grp = 
rep(c("grp1", "grp2"), c(10,10)), val = rnorm(20))
dat
bwplot(val ~ grp | panvar, data = dat)
# End R-code

As in my real life data the number of observations in each subgroup will be 
quite different, I would like to include the number of observations each 
boxplot is based upon.
Aggregation will tell me the numbers:
# Begin R-code
aggregate(dat$val, by = list(dat$panvar, dat$grp), FUN = length)
# End R-code
But how to match these numbers with the plot (so that for example "n=3" will be 
written as text beneath panel A/group1)?

Any advice would be appreciated;
kind regards
Heinrich.

______________________________________________
R-help@r-project.org 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.

Reply via email to