I am new to R and have been trying to fit a nonlinear model to some data, unsuccessfully though. In the end I added a polynomial trendline in Excel and tried to plot the function I got - for some reason the function doesn't fit my data in R. I tried the simple geom_smooth, but achieved a "bulky" line, I want a smooth one. I have 6 samples in one plot, here is the data for one of them, including the function obtained by Excel and my attempt to plot it. I am sure there is a better way - I also need to get the function of the fit in an output.
datax <- c(0, 21.3, 30, 46.3, 72)
datay <- c(0, 0.008723333, 0.016253333, 0.039896667, 0.079893333)
data <- data.frame(datax, datay)
x <- seq(0, 0.01, length.out = 72)
poly.fit <- function(x) 1E-5*x^2+0.0002*x
ggplot(data, aes(x=datax, y=datay)) +
geom_point() +
stat_function(fun=poly.fit)