Learn R Programming

car (version 3.0-12)

Boxplot: Boxplots With Point Identification

Description

Boxplot is a wrapper for the standard R boxplot function, providing point identification, axis labels, and a formula interface for boxplots without a grouping variable.

Usage

Boxplot(y, ...)

# S3 method for default Boxplot(y, g, id=TRUE, xlab, ylab, ...)

# S3 method for formula Boxplot(formula, data=NULL, subset, na.action=NULL, id=TRUE, xlab, ylab, ...)

# S3 method for list Boxplot(y, xlab="", ylab="", ...)

# S3 method for data.frame Boxplot(y, id=TRUE, ...)

# S3 method for matrix Boxplot(y, ...)

Arguments

y

a numeric variable for which the boxplot is to be constructed; a list of numeric variables, each element of which will be treated as a group; a numeric data frame or a numeric matrix, each of whose columns will be treated as a group.

g

a grouping variable, usually a factor, for constructing parallel boxplots.

id

a list of named elements giving one or more specifications for labels of individual points ("outliers"): n, the maximum number of points to label (default 10); location, "lr" (left or right) of points or "avoid" to try to avoid overplotting; method, one of "y" (automatic, the default), "identify" (interactive), or "none"; col for labels (default is the first color in carPalette() ); and cex size of labels (default is 1). Can be FALSE to suppress point identification or TRUE (the default) to use all defaults. This is similar to how showLabels handles point labels for other functions in the car package, except that the usual default is id=FALSE.

xlab, ylab

text labels for the horizontal and vertical axes; if missing, Boxplot will use the variable names, or, in the case of a list, data frame, or matrix, empty labels.

formula

a `model' formula, of the form ~ y to produce a boxplot for the variable y, or of the form y ~ g, y ~ g1*g2*..., or y ~ g1 + g2 + ... to produce parallel boxplots for y within levels of the grouping variable(s) g, etc., usually factors.

data, subset, na.action

as for statistical modeling functions (see, e.g., lm).

further arguments, such as at, to be passed to boxplot.

References

Fox, J. and Weisberg, S. (2019) An R Companion to Applied Regression, Third Edition, Sage.

See Also

boxplot

Examples

Run this code
# NOT RUN {
Boxplot(~income, data=Prestige, id=list(n=Inf)) # identify all outliers
Boxplot(income ~ type, data=Prestige)
Boxplot(income ~ type, data=Prestige, at=c(1, 3, 2))
Boxplot(k5 + k618 ~ lfp*wc, data=Mroz)
with(Prestige, Boxplot(income, id=list(labels=rownames(Prestige))))
with(Prestige, Boxplot(income, type, id=list(labels=rownames(Prestige))))
Boxplot(scale(Prestige[, 1:4]))
# }

Run the code above in your browser using DataLab