ctab {catspec} | R Documentation |
Prints one-way, two-way or multiway percentage tables
ctab(..., digits = 2, type = c("n", "row", "column", "total"), row.vars = NULL, col.vars = NULL, percentages = TRUE)
... |
one or more factors or a table object of class table , xtabs , or
ftable |
digits |
number of decimal places (default 2) |
type |
Row, column, total percentages or counts (type=n ) |
row.vars |
|
col.vars |
Same as ftable |
percentages |
If FALSE , proportions rather than percentages are printed |
Simplifies the production of (multiway) percentage tables.
For one-way and two-way tables, a table
object is returned. For three-way and higher tables,
an ftable
object is returned.
If the table contains three or more factors, the first is treated by default as the row variable, the
second as the column variable, the third and following as grouping variables. This can be overridden
using row.vars
and/or col.vars
. Note that CrossTable
in
the gregmisc
package also provides an easy method for producing percentage tables but only for
two-way tables.
John Hendrickx <John_Hendrickx@yahoo.com>
table
, ftable
, xtabs
, prop.table
,
CrossTable
data(Titanic) ctab(Titanic) ctab(Titanic,type="r") ctab(Titanic,row.vars=1:3,type="r") ctab(Titanic,col.vars=c(2,4),type="r") ctab(Titanic,row.vars=c(1,3),type="c") ctab(Titanic,col.vars=c("Sex","Survived"),type="r") ctab(Titanic,col.vars=c("Sex","Survived"),type="t")