Why is the first bar so big in my R histogram?

Viewed 1019

I'm playing around with R. I try to visualize the distribution of 1000 dice throws with the following R script:

cases <- 1000

min <- 1
max <- 6

x <- as.integer(runif(cases,min,max+1))
mx <- mean(x)
sd <- sd(x)

hist(
  x,
  xlim=c(min - abs(mx/2),max + abs(mx/2)),
  main=paste(cases,"Samples"),
  freq = FALSE,
  breaks=seq(min,max,1)
)

curve(dnorm(x, mx, sd), add = TRUE, col="blue", lwd = 2)
abline(v = mx, col = "red", lwd = 2)

legend("bottomleft", 
       legend=c(paste('Mean (', mx, ')')), 
       col=c('red'), lwd=2, lty=c(1))

The script produces the following histogram: histogram

Can someone explain to me why the first bar is so big? I've checked the data and it looks fine. How can I fix this?

Thank you in advance!

3 Answers
Related