-3

I am supposed to draw an overlay normal curve over a histogram in R. I am using the following code.

g <- unesco$Infant.Deaths
hist(g)
lines(seq(0, 200, by=5), dnorm(seq(0, 200, by=5),
                                mean(g), sd(g)), col="blue")

But instead of a curve, I am getting a straight line enter image description here

R.N
  • 109
  • 1
  • 6

1 Answers1

1

It can be, that your histogram is representing frequencies instead of probability densities. Try to use hist(g, freq = FALSE).

R18
  • 920
  • 5
  • 16