Learn R Programming

questionr (version 0.2)

rprop: Row percentages of a two-way frequency table.

Description

Return the row percentages of a two-way frequency table with formatting and printing options.

Usage

rprop(tab, digits = 1, total = TRUE, percent = FALSE,
    drop = TRUE)

Arguments

tab
frequency table
digits
number of digits to display
total
if TRUE, add a column with the sum of percentages and a row with global percentages
percent
if TRUE, add a percent sign after the values when printing
drop
if TRUE, lines or columns with a sum of zero, which would generate NaN percentages, are dropped.

Value

  • The result is an object of class table and proptab.

See Also

cprop, prop, table, prop.table

Examples

Run this code
## Sample table
data(Titanic)
tab <- apply(Titanic, c(1,4), sum)
## Column percentages
rprop(tab)
## Column percentages with custom display
rprop(tab, digits=2, percent=TRUE, total=FALSE)

Run the code above in your browser using DataLab