Learn R Programming

mosaic (version 0.9-0)

freqpolygon: Frequency Polygons

Description

Frequency polygons are an alternative to histograms that make it simpler to overlay multiple distributions.

Usage

freqpolygon(x, ..., panel = "panel.freqpolygon")

panel.freqpolygon(x, plot.points = "jitter", ref = FALSE, groups = NULL, weights = NULL, jitter.amount = 0.01 * diff(current.panel.limits()$ylim), type = "density", breaks = NULL, nint = NULL, center = NULL, wdth = NULL, width = wdth, gcol = trellis.par.get("reference.line")$col, glwd = trellis.par.get("reference.line")$lwd, h, v, ..., identifier = "density")

Arguments

x
a formula or a numeric vector
...
additional arguments passed on to histogram and panel.
panel
a panel function
plot.points
one of TRUE, FALSE, "jitter", or "rug" indicating how points are to be displayed
gcol
color of guidelines
glwd
width of guidelines
groups,weights,jitter.amount,identifier
type
one of 'density', 'percent', or 'count'
breaks
a vector of breaks for the frequency polygon bins
nint
an approximate number of bins for the frequency polygon
center
center of one of the bins
width
width of the bins
wdth
alternative to width to avoid conflict with densityplot argument names
h,v
a vector of values for additional horizontal and vertical lines
ref
a logical indicating whether a horizontal reference line should be added (roughly equivalent to h=0)

Value

  • a trellis object

Details

These functions are still under development. Future improvements may be forthcoming.

Examples

Run this code
freqpolygon(~age | substance, data=HELPrct, v=35)
freqpolygon(~age, data=HELPrct, labels=TRUE, type='count')
freqpolygon(~age | substance, data=HELPrct, groups=sex)
freqpolygon(~age | substance, data=HELPrct, groups=sex, ylim=c(0,0.11))
## comparison of histogram and frequency polygon
histogram(~eruptions, faithful, type='density', width=.5)
ladd( panel.freqpolygon(faithful$eruptions, width=.5 ))

Run the code above in your browser using DataLab