[R] hist and normal curve
Bill Simpson
wsi at gcal.ac.uk
Mon Oct 15 10:20:04 CEST 2001
On Sat, 13 Oct 2001, Erin Hodgess wrote:
> Dear R people:
>
> I would like to superimpose a normal curve on a histogram.
x<-rnorm(150)
h<-hist(x,breaks=15)
xhist<-c(min(h$breaks),h$breaks)
yhist<-c(0,h$density,0)
xfit<-seq(min(x),max(x),length=40)
yfit<-dnorm(xfit,mean=mean(x),sd=sd(x))
plot(xhist,yhist,type="s",ylim=c(0,max(yhist,yfit)))
lines(xfit,yfit)
Bill
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list