[R] "contingency table" for several variables

Frank E Harrell Jr f.harrell at vanderbilt.edu
Tue Feb 20 15:56:59 CET 2007


David LEVY wrote:
> DearList,
> 
> 
> 
> I ‘m trying to draw ONE table that summarize SEVERAL categorical variables
> according to one classification variable, say “sex”. The result would look
> like several contingency tables appended one to the other. All the variables
> belong to a data frame.
> 
> The summary.formula in Hmisc package does something pretty close and is
> ready for a Latex export  but I need either to get rid off the percentage
> (or put the count prior to the percentage )in the “reverse” option or to add
> a chisquare test in the “response” method.

Not a good idea.  The % is normalized for sample size differences so 
should be emphasized.

Frank

> 
> 
> 
> The result would look like the one of
> 
>> summary(sex~treatment+Symptoms, fun = table, method = “response”)
> 
> in the help of  summary.formula but with chisquare tests attached.
> 
> Or :
> 
>> summary(sex~treatment+Symptoms, fun = table, method = “reverse”, test= T)
> 
>  gives all the information, but I can’t use it for its form is not
> appropriate.
> 
> 
> 
> Is there any package where I could find a solution ? Any way to create a
> function that would add a test in the “response” method ?
> 
> Otherwise, ftable should help but I don’t know how to use it with a
> data.frame.
> 
> 
> 
> Thanks for your help.
> 
> Regards,
> 
> David
> 
> 	[[alternative HTML version deleted]]
> 
> 
> 
> ------------------------------------------------------------------------
> 
> ______________________________________________
> R-help at 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.


-- 
Frank E Harrell Jr   Professor and Chair           School of Medicine
                      Department of Biostatistics   Vanderbilt University



More information about the R-help mailing list