This method for the generic function hist
is mainly
useful to plot the histogram of grouped data. If plot = FALSE
,
the resulting object of class "histogram"
is returned for
compatibility with hist.default
, but does not contain
much information not already in x
.
# S3 method for grouped.data
hist(x, freq = NULL, probability = !freq,
density = NULL, angle = 45, col = NULL, border = NULL,
main = paste("Histogram of" , xname),
xlim = range(x), ylim = NULL, xlab = xname, ylab,
axes = TRUE, plot = TRUE, labels = FALSE, ...)
An object of class "histogram"
which is a list with components:
the \(r + 1\) group boundaries.
\(r\) integers; the frequency within each group.
the relative frequencies within each group
\(n_j/n\), where \(n_j\) = counts[j]
.
same as density
. Deprecated, but retained
for compatibility.
the \(r\) group midpoints.
a character string with the actual x
argument name.
logical, indicating if the distances between
breaks
are all the same.
an object of class "grouped.data"
; only the first
column of frequencies is used.
logical; if TRUE
, the histogram graphic is a
representation of frequencies, the counts
component of
the result; if FALSE
, probability densities, component
density
, are plotted (so that the histogram has a total area
of one). Defaults to TRUE
iff group boundaries are
equidistant (and probability
is not specified).
an alias for !freq
, for S compatibility.
the density of shading lines, in lines per inch.
The default value of NULL
means that no shading lines
are drawn. Non-positive values of density
also inhibit the
drawing of shading lines.
the slope of shading lines, given as an angle in degrees (counter-clockwise).
a colour to be used to fill the bars.
The default of NULL
yields unfilled bars.
the color of the border around the bars. The default is to use the standard foreground color.
these arguments to title
have useful
defaults here.
the range of x and y values with sensible defaults.
Note that xlim
is not used to define the histogram
(breaks), but only for plotting (when plot = TRUE
).
logical. If TRUE
(default), axes are draw if the
plot is drawn.
logical. If TRUE
(default), a histogram is
plotted, otherwise a list of breaks and counts is returned.
logical or character. Additionally draw labels on top
of bars, if not FALSE
; see plot.histogram
.
further graphical parameters passed to
plot.histogram
and their to title
and
axis
(if plot=TRUE
).
Klugman, S. A., Panjer, H. H. and Willmot, G. E. (1998), Loss Models, From Data to Decisions, Wiley.
hist
and hist.default
for histograms of
individual data and fancy examples.