Re: [Rd] lm, weights and ...

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Sun 03 Sep 2006 - 16:26:09 GMT

"hadley wickham" <h.wickham@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@biostat.ku.dk)                  FAX: (+45) 35327907

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Mon Sep 04 02:29:28 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 06 Sep 2006 - 11:39:23 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.