weighted.table {descriptio}R Documentation

Computes a (possibly weighted) contingency table

Description

Computes a contingency table from one or two vectors, with the possibility of specifying weights.

Usage

weighted.table(x, y = NULL, weights = NULL, stat = "freq",
              mar = FALSE, na.rm = FALSE, na.value = "NA", digits = 1)

Arguments

x

an object which can be interpreted as factor

y

an optional object which can be interpreted as factor

weights

numeric vector of weights. If NULL (default), uniform weights (i.e. all equal to 1) are used.

stat

character. Whether to compute a contingency table ("freq", default), percentages ("prop"), row percentages ("rprop") or column percentages ("cprop").

mar

logical, indicating whether to compute margins. Default is FALSE.

na.rm

logical, indicating whether NA values should be silently removed before the computation proceeds. If FALSE (default), an additional level is added to the variables (see na.value argument).

na.value

character. Name of the level for NA category. Default is "NA". Only used if na.rm = FALSE.

digits

integer indicating the number of decimal places (default is 1)

Value

Returns a contingency table.

Author(s)

Nicolas Robette

See Also

table, assoc.twocat

Examples

data(Movies)
weighted.table(Movies$Country, Movies$ArtHouse)

[Package descriptio version 1.3 Index]