Possible Duplicate:
Fitting a density curve to a histogram in R
best fitting curve from plot in R
I have a set of data that when plotted in a histogram is a Gaussian distribution. I have read the data in from a .csv file that looks like this:
"values"
1.29989
1.15652
1.27818
1.19699
1.28243
1.19433
1.10991
...
using data<-read.csv("~/peak.csv")
... so I create a histogram using hist(data$values)
.
I want to be able to fit a Gaussian to this histogram and compare the fitted function's sigma and mean to the sigma and mean calculated from the data.
Everywhere that I have looked mentions nls
and glm
but I cannot figure out how to use these functions to fit a Gaussian to a histogram, even after doing ?nls
and ?glm
. Please help?