proportions: Express Table Entries as Fraction of Marginal Table

Description Usage Arguments Value Note Author(s) See Also Examples

Description

Returns conditional proportions given margins, i.e. entries of x, divided by the appropriate marginal sums.

Usage

1
2
proportions(x, margin = NULL)
prop.table(x, margin = NULL)

Arguments

x

table

margin

a vector giving the margins to split by. E.g., for a matrix 1 indicates rows, 2 indicates columns, c(1, 2) indicates rows and columns. When x has named dimnames, it can be a character vector selecting dimension names.

Value

Table like x expressed relative to margin

Note

prop.table is an earlier name, retained for back-compatibility.

Author(s)

Peter Dalgaard

See Also

marginSums. apply, sweep are a more general mechanism for sweeping out marginal statistics.

Examples

1
2
3
4
5
6
7
8
m <- matrix(1:4, 2)
m
proportions(m, 1)

DF <- as.data.frame(UCBAdmissions)
tbl <- xtabs(Freq ~ Gender + Admit, DF)

proportions(tbl, "Gender")