Learn R Programming

weights (version 1.1.2)

wtd.boxplot: Weighted boxplot

Description

wtd.boxplot produces boxplots for weighted data by group, accounting for weights when computing medians and quartiles.

Usage

wtd.boxplot(x, group = NULL, weight = NULL, show.outliers = TRUE,
            whisker.mult = 1.5, box.col = "lightgray", border = "black", ...)

Value

A base R graphic is produced showing weighted boxplots by group. No value is returned.

Arguments

x

Numeric vector of values.

group

Optional grouping factor.

weight

Optional numeric vector of weights. If NULL, equal weights are assumed.

show.outliers

Logical. If TRUE, show weighted outliers based on interquartile range.

whisker.mult

Numeric multiplier for the IQR to define whiskers (default is 1.5, as in standard boxplots).

box.col

Color for the box portion of the plot.

border

Color for the boxplot borders.

...

Additional graphical parameters passed to plot or rect.

Author

Josh Pasek

See Also

boxplot, wtd.quantile, wtd.median

Examples

Run this code
set.seed(123)
x <- rnorm(100)
group <- rep(letters[1:2], each = 50)
w <- runif(100, 0.5, 2)
wtd.boxplot(x, group, weight = w)

Run the code above in your browser using DataLab