I have been using the package nls" for a while, but it doesn't work in some situations. So I decided to try nlsr". But I am stuck. My problem is how do I give a function as a formula like in ``nls"

rm(list=ls()) # clear before starting
weed = c(5.308, 7.24, 9.638, 12.866, 17.069, 23.192, 31.443,
38.558, 50.156, 62.948, 75.995, 91.972)
tt = 1:12
weeddf = data.frame(tt, weed)
st = c(b1=1, b2=1, b3=1) # a default starting vector (named!)
wmodu = weed ~ b1/(1 + b2 * exp(- b3 * tt))
# I want to give the above as a function.
wmod = function(tt,b1,b2,b3){
return(b1/(1 + b2 * exp(- b3 * tt)))
}
anlxb1un = nlxb(wmodu, start=st, trace=FALSE, data=weeddf)
print(anlxb1un)
# the above two lines work
anlxb1un1 = nlxb(weed~wmod(tt,b1,b2,b3), start=st, trace=FALSE, data=weeddf)
# the above produces the following error message
Error in deriv.default(residexpr, names(pvec)) :
Function 'wmod' is not in the derivatives table
anlxb1un2 = nls(weed~wmod(tt,b1,b2,b3), start=st, trace=FALSE, data=weeddf)
# the above works

This traces to the required first argument to nlxb needing to be an object of class formula, including both the LHS and the RHS. wmodu is a formula but wmod as defined in the reprex isn't.

BTW: this is considered poor practice in general and somewhat rude in a reprex. Restarting R is preferred and those answering questions may have other work in progress that they don't want to lose. Not a biggie, but a convention.