wpct {weights}R Documentation

Provides a weighted table of percentages for any variable.

Description

wpct produces a weighted table of the proportion of data in each category for any variable. This is simply a weighted frequency table divided by its sum.

Usage

wpct(x, weight=NULL, na.rm=TRUE, ...)

Arguments

x

x should be a vector for which a set of proportions is desired.

weight

weight is a vector of weights to be used to determining the weighted proportion in each category of x.

na.rm

If na.rm is true, missing data will be dropped. If na.rm is false, missing data will return an error.

...

... (optional) Additional arguments to be passed on to wtd.table.

Value

A table object of length equal to the number of separate values of x.

Author(s)

Josh Pasek, Assistant Professor of Communication Studies at the University of Michigan (www.joshpasek.com).

Examples

test <- c(1,1,1,1,1,1,2,2,2,3,3,3,4,4)
weight <- c(.5,.5,.5,.5,.5,1,1,1,1,2,2,2,2,2)

wpct(test)
wpct(test, weight)

[Package weights version 1.0.4 Index]