Learn R Programming

rafalib (version 1.0.0)

shist: smooth histogram

Description

a smooth histogram with unit indicator (we're simply scaling the kernel density estimate). The advantage of this plot is its interpretability since the height of the curve represents the frequency of a interval of size unit around the point in question. Another advantage is that if z is a matrix, curves are plotted together.

Usage

shist(z, unit, bw = "nrd0", n, from, to, plotHist = FALSE, add = FALSE, xlab, ylab = "Frequency", xlim, ylim, main, ...)

Arguments

z
the data
unit
the unit which determines the y axis scaling and is drawn
bw
arguments to density
n
arguments to density
from
arguments to density
to
arguments to density
plotHist
a logical: should an actual histogram be drawn under curve?
add
a logical: add should the curve be added to existing plot?
xlab
x-axis title, defaults to no title
ylab
y-axis title, defaults to no title
xlim
range of the x-axis
ylim
range of the y-axis
main
an overall title for the plot: see title.
...
arguments to lines

Examples

Run this code
set.seed(1)
x = rnorm(50)
par(mfrow=c(2,1))
hist(x, breaks=-5:5)
shist(x, unit=1, xlim=c(-5,5))

Run the code above in your browser using DataLab