qboxplot: Quantile-Based Boxplots

Description Usage Arguments Value Examples

View source: R/qboxplot.R

Description

Produce quantile-based box-and-whisker plot(s) of the given (grouped) values.

Usage

1
2
3
4
5
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 y ~ grp, where y is a numeric vector of data values to be split into groups according to the grouping variable grp (usually a factor), or a data frame specifying data from which the boxplots are to be produced.

range

this determines how far the plot whiskers extend out from the box. If range is positive, the whiskers extend to the most extreme data point which is no more than range times the difference between the value of the upper hinge and the value of the lower hinge from the box. A value of zero causes the whiskers to extend to the data extremes.

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 quantile).

data

a data.frame (or list) from which the variables in formula should be taken.

width

a vector giving the relative widths of the boxes making up the plot.

varwidth

if varwidth is TRUE, the boxes are drawn with widths proportional to the square-roots of the number of observations in the groups.

outline

if outline is FALSE, the outliers are not drawn.

names

group labels which will be printed under each boxplot.

plot

if TRUE then a boxplot is produced. If not, the summaries which the boxplots are based on are returned.

border

an optional vector of colours for the outlines of the boxplots. The values in border are recycled if the length of border is less than the number of plots.

col

if col is non-null it is assumed to contain colors to be used to colour the bodies of the box plots. By default they are in the background colour.

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 FALSE means vertical boxes.

add

logical, if TRUE add boxplot to current plot.

at

numeric vector giving the locations where the boxplots should be drawn; defaults to 1:n where n is the number of boxes.

...

other arguments (see boxplot).

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 out whose elements indicate to which group the outlier belongs.

names

a vector of names for the groups.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#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)

qboxplot documentation built on May 2, 2019, 8:35 a.m.

Related to qboxplot in qboxplot...