[R] Use of ellipsis

Bert Gunter bgunter@4567 @end|ng |rom gm@||@com
Thu May 26 22:00:30 CEST 2022


Inline below.
Bert Gunter

...
"
> Any hints as to why this error occurs would be appreciated. I found [1],
> but I don't think that's relevant, since as far as I can tell, there
> should be no non-standard evaluation here.
>
> [1] https://stat.ethz.ch/pipermail/r-help/2010-February/228881.html
"


You are mistaken. Evaluation of any of the arguments in `data` **is**
exactly what is meant by nse.
?lm explicitly says:
"All of weights, subset and offset are evaluated in the same way as
variables in formula, that is first in data and then in the
environment of formula."

The following is one simple, but somewhat sloppy, way to handle it
(insufficient argument checking):
fit_model2 <- function(formula, data,...){
   arglist <- c(list(formula = formula, data = data),list(...))
   do.call(lm, arglist)
}
fit_model2(y ~ x1 + x2, data = data, weights = rep(1, 100))     ## works



>
>
>
> Andreas Matre
>
> ______________________________________________
> R-help using 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.



More information about the R-help mailing list