I have an array of data - arr = c(1,2,3,4,5,6,1,2,3,4). I draw a histogram and get the following graph
The frequency of 1,2,3,4 is going to be 2 for each of those numbers - but the graph shows different result - it shows 4 for the bin between 1 and 2. Can someone explain why ?
Also, If i plot the probability density function - how are the y-axis and x-axis values for the density plot calculated ?
[![enter image description here]]
h<-hist(x, breaks=10, col="red", xlab="random numbers",
+ main="Histogram with Normal Curve")
xfit<-seq(min(x),max(x),length=40) yfit<-dnorm(xfit,mean=mean(x),sd=sd(x)) yfit <- yfit*diff(h$mids[1:2])*length(x) lines(xfit, yfit, col="blue", lwd=2) xfit