Learn R Programming

sfsmisc (version 0.9-4)

hist.bxp: Plot a Histogram and a Boxplot

Description

Creates a histogram and a horizontal boxplot on the current graphics device.

Usage

hist.bxp(x, nclass, breaks, probability=FALSE, include.lowest=TRUE,
         xlab = deparse(substitute(x)),
         ...,
         width=0.2, boxcol=3, medcol=0, 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])<="" code=""> except that if include.lowest is TRUE (the default), the first bar also includes po
probability
logical flag: if TRUE, the histogram will be scaled as a probability density; the sum of the bar heights times bar widths will equal 1. If FALSE, 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 the breaks argument).
xlab
character or expression for x axis labeling.
...
additional arguments to barplot. The hist function uses the function barplot to do the actual plotting; consequently, arguments to the
width
width of the box relative to the height of the histogram. DEFAULT is 0.2.
boxcol
filled box color. A color of 0 can be used to designate filling with the background color. The default is to fill with color 3.
medcol
the color of the median line. The special value, NA, indicates the current plotting color (par("col")). The default is 0 (the background color). If boxcol=0 and medcol is not exp
medlwd
median line width. The special value NA, is used to indicate the current line width (par("lwd")). The default is 5.
whisklty
whisker line type. The special value NA indicates the current line type (par("lty")). The default is 2 (dotted line).
staplelty
staple (whisker end cap) line type. The special value NA indicates the current line type (par("lty")). The default is 1 (solid line).

Graphical parameters (see par

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.

See Also

hist, barplot, boxplot, rug and scat1d in the Hmisc package.

Examples

Run this code
lab <- "50 samples from a t distribution with 5 d.f."
 mult.fig(2*3, main = "Hist() + Rug()   and    Hist.bxp(*)")
 for(i in 1:3) {
   my.sample <-  rt(50, 5)
   hist(my.sample, main=lab); rug(my.sample)# for 50 obs., this is ok, too..
   hist.bxp(my.sample, main=lab)
 }

Run the code above in your browser using DataLab