[R] Add the Gauss curve on histogram

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Tue Mar 17 02:30:54 CET 2015


Not reproducible (sample data missing).

http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

On March 16, 2015 5:34:18 PM PDT, varin sacha <varinsacha at yahoo.fr> wrote:
>Dear R-Experts,
>
>I can easily plot an histogram and its density curve. But when I try to
>add the Gauss curve on the histogram with the following Rcode here
>below, I don't get it. What is wrong ? Or what is missing in my code ?
>
>##Plot an histogram
>h=hist(newdata$math.test, prob=TRUE, col="blue", border="white",
>xlab="Note test math", ylab="Densité", main="Test math") 
>
>##Add the density curve on the histogram
>lines(density(newdata$math.test,na.rm=TRUE),lwd=2,col="orange") 
>
>##Add the Gauss curve on the histogram
>x <- seq(from = min(newdata$math.test, na.rm=TRUE), to =
>max(newdata$math.test, na.rm=TRUE), lines(x, dnorm(x,
>mean(newdata$math.test, na.rm = TRUE), sd(newdata$math.test, na.rm =
>TRUE))) 
>
>
>Best, thanks for your time.
>
>______________________________________________
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>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.



More information about the R-help mailing list