[R] Cross-tabulations next to each other

From: Charilaos Skiadas <skiadas_at_hanover.edu>
Date: Thu 22 Feb 2007 - 15:01:33 GMT


I have the following relatively simple problem. Say we have three factors, and we want to create a cross-tabulation against each of the other two:

x <- factor(rbinom(5, 1, 1/2))
y <- factor(rbinom(5, 1, 1/2))
z <- factor(rbinom(5, 1, 1/2))

table(x,y)
table(x,z)

This looks like:

    y
x 0 1

   0 2 0
   1 1 2

    z
x 0 1

   0 1 1
   1 2 1

I would like to get (surely this will look a mess in non-monospaced fonts):

    y z
x 0 1 0 1

   0 2 0 1 1
   1 1 2 2 1

Or something along those lines. Then I would like to convert this to a LaTeX table, in the obvious sort of way.

I couldn't find an answer with a quick look through the documentation. Are these two things already done, before I try to roll my own?

Haris Skiadas
Department of Mathematics and Computer Science Hanover College



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri Feb 23 02:18:16 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 22 Feb 2007 - 16:30:34 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.