[R] working with groups of labels?
Richard.Cotton at hsl.gov.uk
Richard.Cotton at hsl.gov.uk
Mon May 11 18:24:58 CEST 2009
It seems that the structure of your data is that you have two groups
("Real Bad Stuff" and "Other Crazy Things") which are then subdivided into
further categories. I'd be tempted to set your data up like this:
dfr <- data.frame(
score=c(23, 14, 17, 8, 43, 13),
group=rep(c("Real Bad Stuff", "Other Crazy Things"), each=3),
variable=c("Real","Bad","Stuff","Other","Crazy","Things"))
Then you can use a lattice plot to emphasise the different groups, and
avoid your mtext worries.
library(lattice)
barchart(
variable~score|group,
data=dfr,
horizontal=TRUE,
layout=c(1,2),
scales=list(y=list(relation="free")),
prepanel=function(x,y,...)
{
y <- y[,drop=TRUE]
prepanel.default.bwplot(x,y,...)
},
panel=function(x,y,...)
{
y <- y[,drop=TRUE]
panel.barchart(x,y,...)
}
)
(The scales, prepanel and panel arguments are just to get rid of the
variables that appear in one group but not the other.) I realise it isn't
exactly what you asked for, but I thought you might be interested in the
alternate approach.
Regards,
Richie.
Mathematical Sciences Unit
HSL
------------------------------------------------------------------------
ATTENTION:
This message contains privileged and confidential inform...{{dropped:20}}
More information about the R-help
mailing list