hplot: Histogram allowing forced number of bins

hplotR Documentation

Histogram allowing forced number of bins

Description

Plots a histogram in the same manner as hist, but with the following changes: freq = FALSE by default, to print the density instead of the frequency and nclass specifies the exact number of bins to use (calculated by equally separating the distance between the min and max value to be graphed)

Usage

hplot(x, breaks = "Sturges", freq = FALSE, nclass = NULL, col = 8, ...) 

Arguments

x

a vector of values for which the histogram is desired.

breaks

see hist for the use of this option. If both breaks and nclass are specified, then breaks is ignored.

freq

logical; if 'FALSE' (default), relative frequencies ("probabilities"), component 'density', are plotted; if 'TRUE', the histogram graphic is a representation of frequencies, the 'counts' component of the result.

nclass

numeric (integer); the number of bins for the histogram. If both breaks and nclass are specified, then breaks is ignored.

col

color of the histogram bars (8, the default, is grey).

...

Other arguments controlling the plot. Many graphical plotting arguments may be used. See help on hist or plot or par for more information.

See Also

hist, plot

Examples

# Create and graph some Normal data
set.seed(100)
set.panel(3,1)
z<- rnorm(100)
hplot(z, nclass=5, main="Standard Normal", xlim=c(-10,10), ylim=c(0,.4))
z<- rnorm(100, sd=2)
hplot(z, nclass=10, main="Std Dev of 2", xlim=c(-10,10), ylim=c(0,.4))
z<- rnorm(100, sd=3)
hplot(z, nclass=15, main="Std Dev of 3", xlim=c(-10,10), ylim=c(0,.4))

Rlab documentation built on May 5, 2022, 1:05 a.m.

Related to hplot in Rlab...