percTable {NCStats}R Documentation

Express table entries as percentage of marginal table.

Description

Same as prop.table() except that it returns percentages rather than proportions.

Usage

  percTable(x, margin = NULL, digits = getOption("digits"),
    addMargins = TRUE)

Arguments

x

A frequency table likely constructed with table().

margin

A numeric representing an index, or vector of indices, to generate the margin for – margin=1 computes row percentages, margin=2 computes column percentages, and margin=NULL (default) produces table percentages.

digits

A numeric indicating the number of decimals to round the percentages to..

addMargins

A logical indicating whether marginal totals should be appended to the table or not. If addMargins=TRUE then the appended marginal totals will correspond to which margin is chosen with margin=.

Value

Same type as x except with percentages of a margin rather than frequencies.

See Also

prop.table, addmargins, and addMargins in FSA.

Examples

Aye <- sample(c("Yes", "Si", "Oui"), 177, replace = TRUE)
Bee <- sample(c("Hum", "Buzz"), 177, replace = TRUE)
( A <- table(Aye, Bee) )

## what prop.table() would look like
prop.table(A,margin=1)

## modified for percTable
# row percentages
percTable(A,margin=1)
percTable(A,margin=1,digits=1)
# column percentages
percTable(A,margin=2)
# table percentages
percTable(A)

## No marginal totals
percTable(A,addMargins=FALSE)

[Package NCStats version 0.3.4 Index]