Plot a Histogram and a Boxplot
histBxp.RdCreates a histogram and a horizontal boxplot on the current graphics device.
Usage
histBxp(x, nclass, breaks, probability=FALSE, include.lowest=TRUE,
xlab = deparse(substitute(x)),
...,
width=0.2, boxcol=3, medcol=2, medlwd=5, whisklty=2, staplelty=1)Arguments
- x
numeric vector of data for histogram. Missing values (
NAs) are allowed.- nclass
recommendation for the number of classes (i.e., bars) the histogram should have. The default is a number proportional to the logarithm of the length of
x.- breaks
vector of the break points for the bars of the histogram. The count in the i-th bar is
sum(breaks[i] < x <= breaks[i+1])except that ifinclude.lowestisTRUE(the default), the first bar also includes points equal tobreaks[1]. If omitted, evenly-spaced break points are determined fromnclassand the extremes of the data.- probability
logical flag: if
TRUE, the histogram will be scaled as a probability density; the sum of the bar heights times bar widths will equal1. IfFALSE, the heights of the bars will be counts.- include.lowest
If
TRUE(the default), the lowest bar will include data points equal to the lowest break, otherwise it will act like the other bars (see the description of thebreaksargument).- xlab
character or expression for x axis labeling.
- ...
additional arguments to
barplot. Thehistfunction uses the functionbarplotto do the actual plotting; consequently, arguments to thebarplotfunction that control shading, etc., can also be given tohist. See thebarplotdocumentation for argumentsangle,density,col, andinside. Do not use thespaceorhistoarguments.- width
width of the box relative to the height of the histogram. DEFAULT is
0.2.- boxcol
color of filled box. The default is
3.- medcol
the color of the median line. The special value,
NA, indicates the current plotting color (par("col")). The default is2. Ifboxcol=0andmedcolis not explicitly specified this is set to the current plotting color (par("col")).- medlwd
median line width. The special value
NA, is used to indicate the current line width (par("lwd")). The default is5.- whisklty
whisker line type. The special value
NAindicates the current line type (par("lty")). The default is2(dotted line).- staplelty
staple (whisker end cap) line type. The special value
NAindicates the current line type (par("lty")). The default is1(solid line).Graphical parameters (see
par) may also be supplied as arguments to this function. In addition, the high-level graphics arguments described underparand the arguments totitlemay be supplied to this function.
Details
If include.lowest is FALSE the bottom breakpoint must be
strictly less than the minimum of the data, otherwise (the default) it
must be less than or equal to the minimum of the data. The top
breakpoint must be greater than or equal to the maximum of the data.
This function has been called hist.bxp() for 17 years; in 2012,
the increasingly strong CRAN policies required a new name (which could not
be confused with an S3 method name).
