powered by
Return the column percentages of a two-way frequency table with formatting and printing options.
cprop(tab, digits = 1, total = TRUE, percent = FALSE, drop = TRUE, n = FALSE)
frequency table
number of digits to display
if TRUE, add a row with the sum of percentages and a column with global percentages
TRUE
if TRUE, add a percent sign after the values when printing
if TRUE, lines or columns with a sum of zero, which would generate NaN percentages, are dropped.
NaN
if TRUE, display number of observations per column.
The result is an object of class table and proptab.
table
proptab
rprop, prop, table, prop.table
rprop
prop
prop.table
## Sample table data(Titanic) tab <- apply(Titanic, c(4,1), sum) ## Column percentages cprop(tab) ## Column percentages with custom display cprop(tab, digits=2, percent=TRUE, total=FALSE)
Run the code above in your browser using DataLab