[R] how to plot the histogram and the curve in the same graph
rroa at udec.cl
Tue Oct 21 14:05:45 CEST 2008
> i want to plot the histogram and the curve in the same graph.if i have a set
> of data ,i plot the histogram and also want to see what distribution it
> was.So i want to plot the curve to know what distribution it like.
To draw the curve and the distribution you should have an idea about the
You cann't just draw the histogram and expect R to make a curve of the
best distribution to fit that histogram.
But you can plot a curve of a kernel density.
x <- rnorm(1000,5,3)
(x.normfit <- fitdistr(x,"normal"))
lines(density(x,na.rm=TRUE),col="red") # kernel density
x.normfit$estimate),col="blue",add=TRUE) #maximum likelihood estimate
More information about the R-help