I'm trying to fit multiple non-linear regression lines and measured points into a plot and started like this:
ggplot(Sorption, aes(x=Ct, y=S, color=Depth)+
geom_point()+
geom_smooth(method = "nls", data = Sorption,
se = FALSE,
formula = 'S~Smax*K*Ct/1+K*Ct',
method.args = list(start=c(K=2, Smax=1100, Ct=0.2, S=0.2)))
The formula in the code is the equation for a langmuir sorption isotherm and all the variables are given in the data=Sorption.
When I run this code, I get the following error:
**fitting parameters ‘K’, ‘Smax’, ‘Ct’, ‘S’ without any variables
Warning message:
Computation failed in `stat_smooth()`:
object 'S' not found**
I have no idea what I'm doing right or wrong, so if anybody has a lead, I'd be forever grateful ;) I'm also not sure about the starting points and what to put in this last line of code. When I'm running this code I do get the actual measured points in the plot but no non-linear regression line.
You can adjust the way you express formula, by using
xandydirectlyAn example is with
mtcarsOutput: