plotDensityHistogram: Histogram with a density curve

View source: R/plotDensityHistogram.r

plotDensityHistogramR Documentation

Histogram with a density curve

Description

Produces a histogram for a vector of values and adds a density curve of the distribution.

Usage

plotDensityHistogram(
  x,
  prob = FALSE,
  col = "gray",
  main = "",
  linecol = "black",
  lwd = 2,
  adjust = 1,
  bw = "nrd0",
  kernel = "gaussian",
  ...
)

Arguments

x

A vector of values.

prob

If FALSE, then counts are displayed in the histogram. If TRUE, then the density is shown.

col

The color of the histogram bars.

main

The title displayed for the plot.

linecol

The color of the line in the plot.

lwd

The width of the line in the plot.

adjust

Passed to density. A lower value makes the density plot smoother.

bw

Passed to density.

kernel

Passed to density.

...

Other arguments passed to hist.

Details

The function relies on the hist function. The density curve relies on the density function.

Value

Produces a plot. Returns nothing.

Author(s)

Salvatore Mangiafico, mangiafico@njaes.rutgers.edu

References

https://rcompanion.org/handbook/C_04.html

See Also

plotNormalHistogram, plotNormalDensity

Examples

### Plot of residuals from a model fit with lm
data(Catbus)
model = lm(Steps ~ Gender + Teacher,
           data = Catbus)
plotDensityHistogram(residuals(model))          


rcompanion documentation built on May 29, 2024, 8:42 a.m.