Skip to contents

Enhancement of dnorm to plot normal distribution or bell curve as an overlay in ggplot2 histograms according to number of records and bin width.

Usage

dnorm_ggplot(x, mean, sd, n, bw)

Arguments

x

vector of values.

mean

vector of means.

sd

vector of standard deviations.

n

The number of records or data points used to plot the histogram.

bw

The bin width of the histogram.

Value

The density for normal distribution.

Examples

dnorm(0) * 25 == dnorm_ggplot(0, mean = 0, sd = 1, n = 5, bw = 5)
#> [1] TRUE
dnorm(1) * 21 == dnorm_ggplot(1, mean = 0, sd = 1, n = 7, bw = 3)
#> [1] TRUE