rprop: Row percentages of a cross-tabulation table (2 dimensions or...

rpropR Documentation

Row percentages of a cross-tabulation table (2 dimensions or more).

Description

Return the row percentages of a cross-tabulation table (2 dimensions or more) with formatting and printing options.

Usage

rprop(tab, ...)

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

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

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

## S3 method for class 'tabyl'
rprop(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 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. Unused for tables of 3 dimensions or more (always 'FALSE').

n

if TRUE, display number of observations per row.

Value

The result is an object of class table and proptab.

See Also

cprop, prop, table, prop.table

Examples

## 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)
## Could be applied to a table of 3 dimensions or more
rprop(Titanic)

questionr documentation built on April 4, 2025, 1:43 a.m.