[R] basic bwplot query

Kieran Healy kjhealy at arizona.edu
Sat Nov 6 23:54:12 CET 2004


Hi -

I have some data consisting of a number of observations within each of 
15 countries. Each country falls into one of two groups. I'd like to 
use the lattice library's bwplot to present boxplots of the 
country-level data, with a separate panel for each group, but showing 
only the relevant countries in each panel.  Here's an analogous example 
using the "singer" data provided with the lattice. Say we assign the 
voice parts to groups, "M" and "F":

tmp <- rep("F",128)
tmp2 <- rep("M",length(129:nrow(singer)))
sex <- c(tmp,tmp2)

We'd like a two-panel figure showing the voice part boxplots for groups 
"M" and "F", but each panel should list only  those voice parts falling 
in its group. This way doesn't quite work:

bwplot(voice.part ~ height | sex, data=singer, xlab="Height 
(inches)",layout=c(1,2))

How can I have rows belonging to the "F" group just not appear at all 
in the "M" panel and vice versa? I guess this is quite straightforward, 
but I'm going about it in the wrong --- do I need to provide some extra 
information about subscripts via a panel function? I'd be grateful for 
any advice.

Thanks,

Kieran

--
Kieran Healy, http://www.u.arizona.edu/~kjhealy
Assistant Professor, Sociology Dept, University of Arizona.




More information about the R-help mailing list