[R] Overlay PDF on histogram

From: James <jctoll_at_gmail.com>
Date: Wed, 12 Dec 2007 09:16:02 -0700


Hi,

I thought that I had read somewhere that there was a really simple way to overlay the probability density function of a normal distribution over a histogram, after the histogram has already been plotted. Possibly a one word command.

I've found this email from the archives, but I don't think this is what I'm looking for. I thought there was something more simple than the curve function.

http://tolstoy.newcastle.edu.au/R/help/05/04/3523.html

R> x <- rnorm(100)
R> hist(x, freq = FALSE)
R> curve(dnorm, col = 2, add = TRUE)

Is there a simple way to do this, or is my memory failing me? Thank you.

James



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 12 Dec 2007 - 16:25:47 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 12 Dec 2007 - 17:30:18 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.