cprop: Column percentages of a two-way frequency table.

cpropR Documentation

Column percentages of a two-way frequency table.

Description

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

Usage

cprop(tab, ...)

## S3 method for class 'table'
cprop(
  tab,
  digits = 1,
  total = TRUE,
  percent = FALSE,
  drop = TRUE,
  n = FALSE,
  ...
)

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

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

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

Arguments

tab

frequency table

...

parameters passed to other methods.

digits

number of digits to display

total

if TRUE, add a row with the sum of percentages and a column 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 column.

Value

The result is an object of class table and proptab.

See Also

rprop, prop, table, prop.table

Examples

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

juba/questionr documentation built on Feb. 4, 2023, 11:45 p.m.