[R] Another newbie question: curve of normal distribution

Uwe Ligges ligges at statistik.uni-dortmund.de
Tue Oct 15 08:52:24 CEST 2002



Matej Cepl wrote:
> 
> I would like to get a curve of normal distrubtion over the
> histogram. Something like the following (which obviously doesn't
> work; see attached example).
> 
>         maluj <- function() {
> 
>         vrhy=read.csv("pennies.csv",head=TRUE)
> 
>         hf=table(vrhy$HEADS)
>         postscript("heads.eps",onefile=FALSE,width=4.134,height=3.445,pointsize=12)
>         plot(hf,main="Frequency distribution of heads",xlab="Throws",
>                 ylab="Frequency")
>         lines(rnorm(length(hf),mean=mean(hf),sd=sd(hf)))

Try
	 curve(function(x) dnorm(x, mean=mean(hf), sd=sd(hf)), 
            add = TRUE, from = min(hf) to = max(hf))

Uwe Ligges

>         dev.off(2)
> 
>         }
> 
> Any help, please?
> 
> Thanks
> 
>         Matej
> 
> --
> Matej Cepl, matej at ceplovi.cz, PGP ID# D96484AC
> 138 Highland Ave. #10, Somerville, Ma 02143, (617) 623-1488
> 
> understand, v.:
>     To reach a point, in your investigation of some subject,
>     at which you cease to examine what is really present, and
>     operate on the basis of your own internal model instead.
> 
>   ------------------------------------------------------------------------
>                 Name: heads.eps
>    heads.eps    Type: Postscript Document (application/postscript)
>             Encoding: quoted-printable
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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