[R] Different labels by panel in barchart
Richard.Cotton at hsl.gov.uk
Richard.Cotton at hsl.gov.uk
Wed Dec 19 10:23:04 CET 2007
Dear all,
I'm analysing a survey, and creating a barchart of the different responses
for each question. The questions are grouped according to a number of
categories, so I'm using lattice to create a plot with each question in a
category on it. The problem is that the response set for different
questions within the same category varies. I want to be able to draw only
the relevant bars, without spaces for nonrelevant reposnes. An example
may make it clearer:
testdf = data.frame(y=c(23,34,45, 56), x=factor(c("a", "a", "b", "c")),
g=factor(c(1,2,1,2)))
barchart(y~x|g, data=testdf)
#In the first panel I would like two columns "a" and "b", positioned at 1
and 2 respectively; in the second I would again like two columns at 1 and
2, this time labelled "a" and "c".
barchart(y~x|g, data=testdf, scales=list(x=list(relation="free")),
drop.unused.levels=TRUE)
#This is closer, but puts the columns in the wrong place in the second
panel.
Regards,
Richie.
Mathematical Sciences Unit
HSL
------------------------------------------------------------------------
ATTENTION:
This message contains privileged and confidential inform...{{dropped:20}}
More information about the R-help
mailing list