qboxplot {qboxplot} | R Documentation |
Quantile-Based Boxplots
Description
Produce quantile-based box-and-whisker plot(s) of the given (grouped) values.
Usage
qboxplot(x, range=1.5, probs=c(0.25,0.5,0.75), qtype=7, data=parent.frame(),
width=NULL, varwidth=FALSE, outline=TRUE, names=NULL, plot=TRUE,
border=par("fg"), col=NULL, log="", pars=list(boxwex=0.8,
staplewex=0.5, outwex=0.5), horizontal=FALSE, add=FALSE, at=NULL,
...)
Arguments
x |
a formula, such as |
range |
this determines how far the plot whiskers extend out from the box. If |
probs |
numeric vector of values in [0,1] specifying the percentiles of the upper hinge, the midpoint (usually the median) and the lower hinge. |
qtype |
an integer between 1 and 9 indicating which one of the nine quantile algorithms to use (see |
data |
a data.frame (or list) from which the variables in |
width |
a vector giving the relative widths of the boxes making up the plot. |
varwidth |
if |
outline |
if |
names |
group labels which will be printed under each boxplot. |
plot |
if |
border |
an optional vector of colours 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 |
a list of (potentially many) more graphical parameters. |
horizontal |
logical indicating if the boxplots should be horizontal; default |
add |
logical, if |
at |
numeric vector giving the locations where the boxplots should be drawn; defaults to |
... |
other arguments (see |
Value
List with the following components:
stats |
a matrix, each column contains the extreme of the lower whisker, the lower hinge, the midpoint, 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. |
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. |
Examples
#Example 1
data = data.frame(a=runif(10), b=runif(10), c=runif(10))
qboxplot(data, range=1.3, probs=c(0.2,0.5,0.7), qtype=6)
#Example 2
qboxplot(count~spray, data=InsectSprays, col="lightgray")
#Example 3
rb = qboxplot(decrease~treatment, data=OrchardSprays, log="y", col="bisque")
title("")
rb
#Example 4
mat = cbind(Uni05=(1:100)/21, Norm=rnorm(100), "5T"=rt(100,df=5),
Gam2=rgamma(100,shape=2))
qboxplot(as.data.frame(mat))
#Example 5
data = c(102,133,136,139,142,144,146,151,160,174)
qboxplot(data.frame(data), range=1.5, probs=c(0.25,0.5,0.75), qtype=1,
ylim=c(100,220), horizontal=TRUE)