Learn R Programming

weights (version 1.1.1)

wtd.barplot: Weighted barplot

Description

wtd.barplot is a wrapper around barplot that creates barplots of counts or proportions using weights. Note that for now this only works in the special case of a single weighted variable. Formulas will be added later.

Usage

wtd.barplot(x, weight = NULL, percent = FALSE, horiz = FALSE, ...)

Value

A barplot is drawn. No value is returned.

Arguments

x

Categorical variable (factor or character).

weight

Optional numeric vector of weights.

percent

If TRUE, display percentages instead of raw counts.

horiz

If TRUE, draw bars horizontally.

...

Additional arguments passed to barplot.

Author

Josh Pasek

See Also

Examples

Run this code
x <- sample(c("Yes", "No"), 100, replace = TRUE)
w <- runif(100, 0.5, 2)
wtd.barplot(x, weight = w)

Run the code above in your browser using DataLab