[R] Add function to histogram?

Gabor Grothendieck ggrothendieck at gmail.com
Wed Sep 21 08:21:03 CEST 2005


On 9/20/05, Robert Lundqvist <Robert.Lundqvist at ltu.se> wrote:
> Is there any neat way to add a curve (frequency function or the like) to a
> histogram or other plots? I haven't found one yet...

Try this:

set.seed(1)
z <- rnorm(100)
library(MASS)
truehist(z)
lines(density(z))
curve(dnorm, color = "red", add = TRUE)




More information about the R-help mailing list