[R] Add the Gauss curve on histogram
    varin sacha 
    varinsacha at yahoo.fr
       
    Tue Mar 17 01:34:18 CET 2015
    
    
  
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.
    
    
More information about the R-help
mailing list