This question is a follow-up to a previous answer which raised a puzzle.
Reproducible example from the previous answer:
Models <- list( lm(runif(10)~rnorm(10)),lm(runif(10)~rnorm(10)),lm(runif(10)~rnorm(10)) )
lm1 <- lm(runif(10)~rnorm(10))
library(functional)
# This works
do.call( Curry(anova, object=lm1), Models )
# But so does this
do.call( anova, Models )
The question is why does do.call(anova, Models)
work fine, as @Roland points out?
The signature for anova is anova(object, ...)
anova
calls UseMethod
, which should* call anova.lm
which should call anova.lmlist
, whose first line is objects <- list(object, ...)
, but object
doesn't exist in that formulation.
The only thing I can surmise is that do.call
might not just fill in ellipses but fills in all arguments without defaults and leaves any extra for the ellipsis to catch? If so, where is that documented, as it's definitely new to me!
* Which is itself a clue--how does UseMethod
know to call anova.lm
if the first argument is unspecified? There's no anova.list
method or anova.default
or similar...