The generic function histsu computes a histogram of the given data values.
histsu(x, breaks = "Sturges", freq = NULL, probability = !freq,
include.lowest = TRUE, right = TRUE, density = NULL, angle = 45, col = NULL,
border = NULL, main = paste("Histogram of", xname), xlim = range(breaks),
ylim = NULL, xlab = xname, ylab, axes = TRUE, plot = TRUE, labels = FALSE,
nclass = NULL, ...)
An object of class "histogram"
which is a list with components:
The n+1 cell boundaries (=breaks
if that was a vector).
N integers; for each cell, the number of x[]
inside.
Values as estimated density values. If all(diff(breaks)
== 1)
, they are the relative frequencies counts/n.
Same as density, deprecated.
The n cell midpoints.
A character string with the actual x
argument name.
Logical, indicating if the distances between breaks
are all the same.
A vector of values for which the histogram is desired.
Either: 1) A vector giving the breakpoints between histogram cells, OR 2) A single number giving the number of cells for the histogram, OR 3) A character string naming an algorithm to compute the number of cells (see Details), OR 4) A function to compute the number of cells.
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 'breaks' are equidistant (and 'probability' is not
specified).
A logical value, TRUE
means it is not a frequency
graph.
If TRUE
, an x[i]
equal to the 'breaks'
value will be included in the first (or last, for right=FALSE
) bar.
This will be ignored (with a warning) unless 'breaks' is a vector.
If TRUE
, the histograms cells are right-closed
(left open) intervals.
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.
Title of the graph.
A two valued vector specifying the lower and upper limits of the x axis.
A two valued vector specifying the lower and upper limits of the y axis.
X axis labels.
Y axis labels.
Logical value, if TRUE
, axis will be drawn.
Logical value, if TRUE
, plot will be drawn.
Logical or character. Additionally draw labels on top of bars,
if not FALSE
; see plot.histogram
.
Number of bins of the histogram.
Other graphical parameters, see par for details.
R development team with modifications by Steve Su
See hist
help file. This function forces the number of class of
histogram to that as specified by the user.
Venables, W. N. and Ripley. B. D. (2002) Modern Applied Statistics with S. Springer.
# See hist for extended example:
junk<-rgamma(1000,5)
# Forcing the number of bins to be 10:
histsu(junk,nclass=10)
Run the code above in your browser using DataLab