I am exploring some data, so the first thing I wanted to do was try to fit a normal (Gaussian) distribution to it. This is my first time trying this in R, so I\'m taking it one
the first error indicates that ggplot2 cannot find the variable 'count', which is used in formula, in data.
Stats take place after mapping, that is, size -> x, and counts -> y.
Here is an example for using nls in geom_smooth:
ggplot(data=myhist, aes(x=size, y=counts)) + geom_point() +
geom_smooth(method="nls", formula = y ~ N * dnorm(x, m, s), se=F,
start=list(m=20, s=5, N=300))
The point is that using x and y, instead of size and counts, in the specification of formula.