From ggrothendieck at gmail.com  Sun Sep  3 18:45:39 2006
From: ggrothendieck at gmail.com (Gabor Grothendieck)
Date: Sun, 3 Sep 2006 12:45:39 -0400
Subject: [Rd] lm, weights and ...
In-Reply-To: <f8e6ff050609030846l462be0f1m1e41ea5ecb2c0414@mail.gmail.com>
References: <f8e6ff050609030846l462be0f1m1e41ea5ecb2c0414@mail.gmail.com>
Message-ID: <971536df0609030945w38f42af6o2f38ce6a05a0651d@mail.gmail.com>

If you change it to:

lm3 <- function(...) eval.parent(substitute(lm(...)))

then it works.

> lm3(mpg ~ wt, weights=cyl, data=mtcars)

Call:
lm(formula = mpg ~ wt, data = mtcars, weights = cyl)

Coefficients:
(Intercept)           wt
      35.50        -4.91


On 9/3/06, hadley wickham <h.wickham at gmail.com> wrote:
> > 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)
>
> Thanks,
>
> Hadley
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>




[Rd] lm, weights and ...
Gabor Grothendieck