[R] multiple crosstabulation
Niklaus Kuehnis
kuehnik_0505 at gmx-topmail.de
Sat Jun 3 13:24:11 CEST 2006
Hi,
Two questions:
1) I have a data.frame of binary factors (x, y, z, ...) and would
like to do tables like "table(a,b)" for any combination of factors,
2 by 2. I.e. I'm looking for the equivalent of
table(x,y)
table(x,z)
table(y,z)
...
Is there a simple way to do this?
2) Similar to the above: I have the same data.frame of binary
factors and would like to do tables like "table(a,b)" for the
combinations of one factor(x) with all the others, i.e. the
equivalent of
table(x,y)
table(x,z)
table(x, ...)
table(x, ...)
...
---------------
table(data.frame) gives too many tables, i.e. it gives 2-by-2 tables
for all the combinations of all the factors. Most of these tables
contain only zeros. The factor levels are named differently for each
factor, so apply(data.frame, 2, table) doesn't make sense.
Any help appreciated,
Niklaus
More information about the R-help
mailing list