tw_tab: Quickly make a two-way table of proportions (percentages)

Description Usage Arguments Details Value Author(s) Examples

View source: R/utility_functions.r

Description

Quickly make a two-way table of proportions (percentages)

Usage

1
tw_tab(x, y, margin = NULL, digs = 1, dnn = NULL, ...)

Arguments

x

Row variable

y

Column variable

margin

See 'prop.table'. Default is joint distribution (all cells sum to 100), 1 for row margins (rows sum to 1), 2 for column margins (columns sum to 1)

digs

Number of digits to round percentages to. Defaults to 1.

dnn

See 'table'. the names to be given to the dimensions in the result (the dimnames names). Defaults to NULL for none.

...

Other arguments to be passed to 'table'.

Details

A wrapper for 'table' and 'prop.table' with the margin labels set by default to NULL and the cells rounded to percents at 1 decimal place.

Value

A contingency table of percentage values.

Author(s)

Kieran Healy

Examples

1
2
3
4
with(gss_sm, tw_tab(bigregion, religion, useNA = "ifany", digs = 1))

with(gss_sm, tw_tab(bigregion, religion, margin = 2, useNA =
    "ifany", digs = 1))

kjhealy/socviz documentation built on July 20, 2020, 7:36 a.m.