[Rd] lm, weights and ...
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Sun Sep 3 18:26:09 CEST 2006
"hadley wickham" <h.wickham at gmail.com> writes:
> > lm2 <- function(...) lm(...)
> > lm2(mpg ~ wt, data=mtcars)
>
> Call:
> lm(formula = ..1, data = ..2)
>
> Coefficients:
> (Intercept) wt
> 37.285 -5.344
>
> > lm2(mpg ~ wt, weights=cyl, data=mtcars)
> Error in eval(expr, envir, enclos) : ..2 used in an incorrect context,
> no ... to look in
>
>
> Can anyone explain why this is happening? (Obviously this is a
> manufactured example, but it crops up in ggplot when you want to
> provide a function to perform smoothing)
Presumably this is due to the nonstandard evaluation of the weights
argument. This is a long story, the short version is that the argument
ought to have been designed to be a model formula, but we haven't been
willing to sacrifice S-PLUS compatibility. A more extensive
white-paper on the issues, written by Thomas Lumley, is at
http://developer.r-project.org/nonstandard-eval.pdf
--
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-devel
mailing list