weighted.table.Rd
Computes a contingency table from one or two vectors, with the possibility of specifying weights.
weighted.table(x, y = NULL, weights = NULL, stat = "freq",
mar = FALSE, na.rm = FALSE, na.value = "NAs", digits = 1)
an object which can be interpreted as factor
an optional object which can be interpreted as factor
numeric vector of weights. If NULL (default), uniform weights (i.e. all equal to 1) are used.
character. Whether to compute a contingency table ("freq", default), percentages ("prop"), row percentages ("rprop") or column percentages ("cprop").
logical, indicating whether to compute margins. Default is FALSE.
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).
character. Name of the level for NA category. Default is "NAs". Only used if na.rm = FALSE.
integer indicating the number of decimal places (default is 1)
Returns a contingency table.
data(Movies)
weighted.table(Movies$Country, Movies$ArtHouse)
#> No Yes
#> Europe 39 33
#> France 212 393
#> Other 6 20
#> USA 257 40