Learn R Programming

questionr (version 0.7.8)

prop: Global percentages of a two-way frequency table.

Description

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

Usage

prop(tab, ...)

prop_table( tab, digits = 1, total = TRUE, percent = FALSE, drop = TRUE, n = FALSE, ... )

# S3 method for data.frame prop( tab, digits = 1, total = TRUE, percent = FALSE, drop = TRUE, n = FALSE, ... )

# S3 method for matrix prop( tab, digits = 1, total = TRUE, percent = FALSE, drop = TRUE, n = FALSE, ... )

# S3 method for tabyl prop(tab, digits = 1, total = TRUE, percent = FALSE, n = FALSE, ...)

Value

The result is an object of class table and proptab.

Arguments

tab

frequency table

...

parameters passed to other methods

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.

n

if TRUE, display number of observations per row and per column.

See Also

rprop, cprop, table, prop.table

Examples

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

Run the code above in your browser using DataLab