

Petr Pikal schrieb:

>Hi
>
>answered hundered times.
>
>  
>
>>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 
>
>above is e.g. Bill Simpson's answer from 2001. Found from R-site 
>search  ***histogram density normal***.
>  
>
Ok If I merge both of your answers I get the graph like in SPSS but the ylab is density instead frequency:
and I do not have the clicks in SPSS to redo the same graph :-(
I hav only the Data file and the SPSS plot.


x<-5+rnorm(150) 

h<-hist(x,breaks=10,freq = TRUE) 
#I need this histogramm  with...

xfit<-seq(min(x),max(x),length=40) 
yfit<-dnorm(xfit,mean=mean(x),sd=sd(x)) 

lines(xfit,yfit) 



h<-hist(x,breaks=10,prob=T) 

xfit<-seq(min(x),max(x),length=40) 
yfit<-dnorm(xfit,mean=mean(x),sd=sd(x)) 
# ... this line 
lines(xfit,yfit)


Thanks Knut


	[[alternative HTML version deleted]]


