I've been playing around with various table tools, trying to construct a
fairly simple cross-tab.  It shouldn't be hard, but for some reason it
turning out to be (for me).

If I want to see how many men and how many women agree with a agree/disagree
question (coded 1,0), I can do this:

>attach(mydata)
>mytable <- table(male, q1.bin) # gender and a binary response variable
>prop.table(mytable, 1) # row percentages
     q1.bin
male      0      1
   0 0.3988 0.6012
   1 0.2879 0.7121

I can repeat that for each of the items I want gender breakdowns for (q2,
q3, q4 ....).   But what I really want is a table that shows the percentage
answering yes (coded as 1) across many, many binary response items.  E.g.,


male q1.bin q2.bin q3.bin ...
   0 0.6012 0.3421 0.9871 ...
   1 0.7121 0.6223 0.0198 ...

I've tried various combinations of apply & cbind, but to no avail. It would
be easy in SPSS crosstabs, but darnit, I want to use R!

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org 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.

Reply via email to