[R] extract fit values from geom_smooth
Joseph Tannhuber
sepp.tannhuber at yahoo.de
Thu Oct 4 22:03:04 CEST 2012
Dear all,
I have a plot with two gaussian distributions:
ggplot( tofdf, aes( x = tof, y = counts ) ) +
geom_histogram( stat = "identity", position = "stack", fill = 2 ) +
geom_smooth( method = "nls", formula = y ~ (a/b)*exp(-(x-c)^2/(2*b^2)) +
(d/e)*exp(-(x-f)^2/(2*e^2)), se=F,
start=list(a=100, b=1, c=695, d=100, e=1, f=710),
control=nls.control(tol=1E-5, minFactor=1/1024),
n = 1000 )
Now I would like to extract some values for further calculations. These are:
1st: mean of the two gauss fits ( c and f )
2nd: ±3 sigma integral of the two gaussians
3rd: minimum between the two gaussians
How can I extract these values from the geom_smooth function?
And is there an easy way to find the minimum?
Thanks in advance
Joseph
More information about the R-help
mailing list