Skip to content

lattice barchart

2 messages · Wilberforce, Deepayan Sarkar

#
I have a data frame with two factors and want to create panel barcharts with
one factor defining the panels and the other the vertical categories by
which I can count the rows of data in each combination of factors. How do I
do this?

I have been trying to use barchart(~factor1|factor2) but it does not give
the panels as I want them.

The data looks like this:

Factor1    Factor2
A             y
B             y
A             x
B             y   
C             x
etc...
1 day later
#
On Tue, Nov 17, 2009 at 3:31 PM, Wilberforce
<will.parry at matrixknowledge.com> wrote:
You need to tabulate your data first; barchart() won't do that for you.

Start with

barchart(xtabs(~Factor1 + Factor2, your.data))

and try using

as.data.frame(xtabs(~Factor1 + Factor2, your.data))

as the data= argument for more flexibility.

-Deepayan