On 28/02/2017 11:07 AM, Rytis Bagdziunas wrote:
Hello everyone,
I've been struggling with the usage of ellipsis argument for stats::nls
and similar functions. In particular, nls manual indicates this:
...: Additional optional arguments. None are used at present.
The documentation is incorrect.
However, "none are used" seems to be slightly misleading. Here's an
example:
data <- data.frame("x" = rnorm(100),
"y" = rnorm(100))
fn <- function(y, a) a * y
## This works
nls(y ~ fn(x, a), data = data, start = list("a" = 1))
## This doesn't
nls(y ~ fn(x, a), data = data, start = list("a" = 1), myarg = FALSE)
## But this does
nls(y ~ fn(x, a), data = data, start = list("a" = 1), myarg = rnorm(100))
traceback() indicates that the additional argument is passed to
model.frame.default() but doesn't appear to do anything.
Is this expected behaviour?
The docs should say "...: additional arguments that may be passed to
model.frame()".
Likely the reason the docs are wrong is that the call to model.frame is
put together in a tricky way, using match.call(), and it's not so
obvious what the conditions are under which it will be called. I don't
see a simple fix to the docs other than what I wrote above.
Duncan Murdoch
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.