I need a histogram for my data, but could not find one with a curve. Can anyone please suggest a histogram showing frequencies (not densitities) with a curve for the data below? Fancy ones are preferred, but no worries if not 🙂
x <- rnorm(1000)
hist(x)
Here’s the slow, step-by-step version.
This is your data.
These are some
xcoordinates for drawing a curve. Notice the use ofqnormto get lower and upper quantiles from a normal distribution.In order to convert from density to counts, we need to know the binwidth. This is easiest if we specify it ourselves.
Here’s our histogram.
The count curve is the normal density times the number of data points divided by the binwidth.
Let’s see that again with the sample distribution rather than the population distribution.