I thought the nls
method had been working in the previous versions of ggplot2
:
df22 <- data.frame(Date = as.Date(c(\"1997-04-23\
In ggplot2
version 2.0.0 and up you need to use method.args
to pass arguments to geom_smooth()
, e.g.:
library(ggplot2)
ggplot(data = df22, aes(x = Date, y = Packages)) +
geom_point() +
geom_smooth(method = 'nls', formula = y ~ exp(a * x + b),
method.args=list(start = c(a = 0.001, b = 3)), se = FALSE)
From the ggplot2 NEWS file (emphasis added):
Layers are now much stricter about their arguments - you will get an error if you've supplied an argument that isn't an aesthetic or a parameter. This is likely to cause some short-term pain but in the long-term it will make it much easier to spot spelling mistakes and other errors (#1293).
This change does break a handful of geoms/stats that used ... to pass additional arguments on to the underlying computation. Now geom_smooth()/stat_smooth() and geom_quantile()/stat_quantile() use method.args instead (#1245, #1289); and stat_summary() (#1242), stat_summary_hex(), and stat_summary2d() use fun.args.