boxplot {base} | R Documentation |
Box Plots
Description
Produce box-and-whisker plot(s) of the given (grouped) values.
Usage
boxplot(x, ...)
boxplot.default(x, ..., range = 1.5, width = NULL,
varwidth = FALSE, notch = FALSE, names, boxwex = 0.8,
data = sys.frame(sys.parent()), plot = TRUE,
border = par("fg"), col = NULL, log = "", pars = NULL)
boxplot.formula(formula, data = NULL, subset, na.action, ...)
Arguments
x |
an R object. |
... |
methods may have additional arguments. |
x , ... |
the data from which the boxplots are to be produced.
The data can be specified as separate vectors, each
corresponding to a component boxplot, or as a single list
containing such vectors. Alternatively a symbolic specification
of the form |
range |
this determines how far the plot whiskers extend out
from the box. If |
width |
a vector giving the relative widths of the boxes making up the plot. |
varwidth |
if |
notch |
if |
names |
group labels which will be printed under each boxplot. |
boxwex |
a scale factor to be applied to all boxes. When there are only a few groups, the appearance of the plot can be improved by making the boxes narrower. |
data |
|
plot |
if |
border |
an optional vector of colors for the outlines of the
boxplots. The values in |
col |
if |
log |
character indicating if x or y or both coordinates should be plotted in log scale. |
pars , ... |
graphical parameters can also be passed as
arguments to |
formula |
a formula, such as |
data |
a data.frame (or list) from which the variables in
|
subset |
an optional vector specifying a subset of observations to be used in the fitting process. |
na.action |
a function which indicates what should happen when
the data contain |
... |
further arguments to the default boxplot method and
graphical parameters may also be passed as arguments, see
|
Details
This is a generic function. It currently has a default method
(boxplot.default
) and a formula interface
(boxplot.formula
).
Value
List with the following components:
stats |
a matrix, each column contains the extreme of the lower whisker, the lower hinge, the median, the upper hinge and the extreme of the upper whisker for one group/plot. |
n |
a vector with the number of observations in each group. |
conf |
a matrix where each column contains the lower and upper extremes of the notch. |
out |
the values of any data points which lie beyond the extremes of the whiskers. |
group |
a vector of the same length as |
names |
a vector of names for the groups |
See Also
boxplot.stats
which does the computation,
bxp
for the plotting, and stripplot
for an
alternative (with small data sets).
Examples
## boxplot on a formula:
data(InsectSprays)
boxplot(count ~ spray, data = InsectSprays, col = "lightgray")
data(OrchardSprays)
boxplot(decrease ~ treatment, data = OrchardSprays,
log = "y", col="bisque")
## boxplot on a matrix:
mat <- cbind(Uni05 = (1:100)/21, Norm = rnorm(100),
T5 = rt(100, df = 5), Gam2 = rgamma(100, shape = 2))
boxplot(data.frame(mat), main = "boxplot(data.frame(mat), main = ...)")