[R] How to make a banner table.

Andrew Choens andy.choens at gmail.com
Mon Dec 1 04:41:11 CET 2008

I have a dataframe with the following variables:

idnum	area	gender	race	etc.

I would like to make a table that looks like

area	gender	race
	M  F	B W A
1	4  5	3 5 1
2	6  7    4 6 3


Basically, I want to make a single broad table with a number of sub-set
tables. I have tried:

cbind(table(area, gender), table(area, race))

But, when I do this, I lose the labels gender / race. This makes it a
lot harder to understand my factor labels. when I use cbind, I get this:

M  F B W A
1 4  5 3 5 1
2 6  7 4 6 3

Although, it is technically correct, I really want to keep my factor
labels. I also tried this with xtabs and get the same results. Any
ideas? I saw a relatively recent thread asking a similar question, but
the proposed solution did not work for me, so I thought I would ask the
questions again.

If I am missing someting terribly obvious, I apologize.


Insert something humorous here.  :-)

More information about the R-help mailing list