[R] Density curve over a histogram

Paul Smith phhs80 at gmail.com
Wed Apr 27 20:22:08 CEST 2005


On 4/27/05, Achim Zeileis <Achim.Zeileis at wu-wien.ac.at> wrote:
> > I would like to draw a picture with the density curve of a normal
> > distribution over a histogram of a set of random numbers extracted
> > from the same normal distribution. Is that possible?
> 
> To quote Simon `Yoda' Blomberg: "This is R. There is no if. Only how."
> (see fortune("Yoda"))
> 
> Try:
> 
> R> x <- rnorm(100)
> R> hist(x, freq = FALSE)
> R> curve(dnorm, col = 2, add = TRUE)

Fantastic! Thanks a lot, Achim.

Paul




More information about the R-help mailing list