ctab {catspec}R Documentation

Percentage tables

Description

Prints one-way, two-way or multiway percentage tables

Usage

ctab(..., digits = 2, type = c("n", "row", "column", "total"),
row.vars = NULL, col.vars = NULL, percentages = TRUE)

Arguments

... 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

Details

Simplifies the production of (multiway) percentage tables.

Value

For one-way and two-way tables, a table object is returned. For three-way and higher tables, an ftable object is returned.

Note

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.

Author(s)

John Hendrickx <John_Hendrickx@yahoo.com>

References

http://www.xs4all.nl/~jhckx/

See Also

table, ftable, xtabs, prop.table, CrossTable

Examples

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")

[Package Contents]