Does anyone know how I can generate a 2x2 table in a format where in each cell of the table, it contains a) count (frequency) b) total percentage c) row percentage d) column percentage. SAS can generate this format easily, is there a R package that can do this? Frequency | Percent | Row Pct | Col Pct | positive negative | Total --------------------------------|------- disease | 6 22 | 28 | 20.69 75.86 | 96.55 | 21.43 78.57 | | 100.00 95.65 | ----------|---------------------|------- normal | 0 1 | 1 | 0.00 3.45 | 3.45 | 0.00 100.00 | | 0.00 4.35 | ----------|---------------------|------- Total | 6 23 | 29 | 20.69 79.31 | 100.00 Thanks
On Wed, 2006-02-01 at 12:16 -0800, array chip wrote:> Does anyone know how I can generate a 2x2 table in a > format where in each cell of the table, it contains a) > count (frequency) b) total percentage c) row > percentage d) column percentage. SAS can generate this > format easily, is there a R package that can do this? > > Frequency | > Percent | > Row Pct | > Col Pct | positive negative | Total > --------------------------------|------- > disease | 6 22 | 28 > | 20.69 75.86 | 96.55 > | 21.43 78.57 | > | 100.00 95.65 | > ----------|---------------------|------- > normal | 0 1 | 1 > | 0.00 3.45 | 3.45 > | 0.00 100.00 | > | 0.00 4.35 | > ----------|---------------------|------- > Total | 6 23 | 29 > | 20.69 79.31 | 100.00 > > ThanksSee the CrossTable() function in the 'gmodels' package on CRAN. HTH, Marc Schwartz
Look at the CrossTable function in the gmodels package. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at intermountainmail.org (801) 408-8111> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of array chip > Sent: Wednesday, February 01, 2006 1:16 PM > To: r-help at stat.math.ethz.ch > Subject: [R] format of 2x2 table > > Does anyone know how I can generate a 2x2 table in a format > where in each cell of the table, it contains a) count > (frequency) b) total percentage c) row percentage d) column > percentage. SAS can generate this format easily, is there a R > package that can do this? > > Frequency | > Percent | > Row Pct | > Col Pct | positive negative | Total > --------------------------------|------- > disease | 6 22 | 28 > | 20.69 75.86 | 96.55 > | 21.43 78.57 | > | 100.00 95.65 | > ----------|---------------------|------- > normal | 0 1 | 1 > | 0.00 3.45 | 3.45 > | 0.00 100.00 | > | 0.00 4.35 | > ----------|---------------------|------- > Total | 6 23 | 29 > | 20.69 79.31 | 100.00 > > Thanks > > ______________________________________________ > 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 >
library(gmodels) ?CrossTable array chip wrote:> Does anyone know how I can generate a 2x2 table in a > format where in each cell of the table, it contains a) > count (frequency) b) total percentage c) row > percentage d) column percentage. SAS can generate this > format easily, is there a R package that can do this? > > Frequency | > Percent | > Row Pct | > Col Pct | positive negative | Total > --------------------------------|------- > disease | 6 22 | 28 > | 20.69 75.86 | 96.55 > | 21.43 78.57 | > | 100.00 95.65 | > ----------|---------------------|------- > normal | 0 1 | 1 > | 0.00 3.45 | 3.45 > | 0.00 100.00 | > | 0.00 4.35 | > ----------|---------------------|------- > Total | 6 23 | 29 > | 20.69 79.31 | 100.00 > > Thanks > > ______________________________________________ > 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-- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 452-1424 (M, W, F) fax: (917) 438-0894