| 1 |
\name{histBxp} |
| 2 |
\alias{histBxp} |
| 3 |
\title{Plot a Histogram and a Boxplot} |
| 4 |
\description{ |
| 5 |
Creates a histogram and a horizontal boxplot on the current graphics |
| 6 |
device. |
| 7 |
} |
| 8 |
\usage{ |
| 9 |
histBxp(x, nclass, breaks, probability=FALSE, include.lowest=TRUE, |
| 10 |
xlab = deparse(substitute(x)), |
| 11 |
\dots, |
| 12 |
width=0.2, boxcol=3, medcol=2, medlwd=5, whisklty=2, staplelty=1) |
| 13 |
} |
| 14 |
\arguments{ |
| 15 |
\item{x}{numeric vector of data for histogram. Missing values |
| 16 |
(\code{NA}s) are allowed.} |
| 17 |
\item{nclass}{ |
| 18 |
recommendation for the number of classes (i.e., bars) the histogram should |
| 19 |
have. The default is a number proportional to the logarithm of the length |
| 20 |
of \code{x}. |
| 21 |
} |
| 22 |
\item{breaks}{ |
| 23 |
vector of the break points for the bars of the histogram. The count in the |
| 24 |
i-th bar is \code{sum(breaks[i] < x <= breaks[i+1])} |
| 25 |
except that if \code{include.lowest} is \code{TRUE} (the default), |
| 26 |
the first bar also includes points equal to \code{breaks[1]}. If |
| 27 |
omitted, evenly-spaced break points are determined from |
| 28 |
\code{nclass} and the extremes of the data. |
| 29 |
} |
| 30 |
\item{probability}{ |
| 31 |
logical flag: if \code{TRUE}, the histogram will be scaled as a probability |
| 32 |
density; the sum of the bar heights times bar widths will equal \code{1}. If |
| 33 |
\code{FALSE}, the heights of the bars will be counts. |
| 34 |
} |
| 35 |
\item{include.lowest}{ |
| 36 |
If \code{TRUE} (the default), the lowest bar will include data |
| 37 |
points equal to the lowest break, otherwise it will act like the |
| 38 |
other bars (see the description of the \code{breaks} argument). |
| 39 |
} |
| 40 |
\item{xlab}{character or expression for x axis labeling.} |
| 41 |
\item{\dots}{additional arguments to \code{\link{barplot}}. The |
| 42 |
\code{\link{hist}} function uses the function \code{barplot} to do |
| 43 |
the actual plotting; consequently, arguments to the \code{barplot} |
| 44 |
function that control shading, etc., can also be given to |
| 45 |
\code{hist}. See the \code{barplot} documentation for arguments |
| 46 |
\code{angle}, \code{density}, \code{col}, and \code{inside}. Do not |
| 47 |
use the \code{space} or \code{histo} arguments. |
| 48 |
} |
| 49 |
\item{width}{ |
| 50 |
width of the box relative to the height of the histogram. DEFAULT is |
| 51 |
\code{0.2}.} |
| 52 |
\item{boxcol}{color of filled box. The default is \code{3}.} |
| 53 |
\item{medcol}{ |
| 54 |
the color of the median line. The special value, \code{NA}, |
| 55 |
indicates the current plotting color (\code{par("col")}). The |
| 56 |
default is \code{2}. If \code{boxcol=0} and \code{medcol} is not |
| 57 |
explicitly specified this is set to the current plotting color |
| 58 |
(\code{par("col")}). |
| 59 |
} |
| 60 |
\item{medlwd}{ |
| 61 |
median line width. The special value \code{NA}, is used to indicate |
| 62 |
the current line width (\code{par("lwd")}). The default is \code{5}. |
| 63 |
} |
| 64 |
\item{whisklty}{ |
| 65 |
whisker line type. The special value \code{NA} indicates the |
| 66 |
current line type (\code{par("lty")}). The default is \code{2} |
| 67 |
(dotted line).} |
| 68 |
\item{staplelty}{ |
| 69 |
staple (whisker end cap) line type. The special value \code{NA} |
| 70 |
indicates the current line type (\code{par("lty")}). The default is |
| 71 |
\code{1} (solid line). |
| 72 |
|
| 73 |
Graphical parameters (see \code{\link{par}}) may also |
| 74 |
be supplied as arguments to this function. |
| 75 |
In addition, the high-level graphics arguments described under |
| 76 |
\code{par} and the arguments to \code{title} may be supplied to this |
| 77 |
function.} |
| 78 |
} |
| 79 |
\details{ |
| 80 |
If \code{include.lowest} is \code{FALSE} the bottom breakpoint must be |
| 81 |
strictly less than the minimum of the data, otherwise (the default) it |
| 82 |
must be less than or equal to the minimum of the data. The top |
| 83 |
breakpoint must be greater than or equal to the maximum of the data. |
| 84 |
|
| 85 |
This function has been called \code{hist.bxp()} for 17 years; in 2012, |
| 86 |
the increasingly strong CRAN policies required a new name (which could not |
| 87 |
be confused with an S3 method name). |
| 88 |
} |
| 89 |
\author{S-Plus: Markus Keller, Christian Keller; port to \R in 1990's: Martin Mächler.} |
| 90 |
|
| 91 |
\seealso{\code{\link{hist}}, \code{\link{barplot}}, |
| 92 |
\code{\link{boxplot}}, \code{\link{rug}} and |
| 93 |
\code{\link[Hmisc]{scat1d}} in the \CRANpkg{Hmisc} package. |
| 94 |
} |
| 95 |
\examples{ |
| 96 |
lab <- "50 samples from a t distribution with 5 d.f." |
| 97 |
mult.fig(2*3, main = "Hist() + Rug() and histBxp(*)") |
| 98 |
for(i in 1:3) { |
| 99 |
my.sample <- rt(50, 5) |
| 100 |
hist(my.sample, main=lab); rug(my.sample)# for 50 obs., this is ok, too.. |
| 101 |
histBxp(my.sample, main=lab) |
| 102 |
} |
| 103 |
} |
| 104 |
\keyword{hplot} |