Re: [Rd] abline for intercept-only simple lm models (with and without offset)

2006-12-11 Thread Martin Maechler
Yes, I think  all your propositions would be improvements.
OTOH, I don't think the improvements warrant a big increase in
code (complexity), nor do I think the improvements are crucial
for R's integrity.

So...
If you (our someone else) provides a patch {against
R-devel, as always} which keeps the code simple,
I'd strongly consider adding that to R.

Regards,
Martin Maechler

> "Tobias" == Tobias Verbeke <[EMAIL PROTECTED]>
> on Sat, 09 Dec 2006 22:42:38 +0100 writes:

Tobias> The abline function can be used to draw the
Tobias> regression line when one passes the lm object as an
Tobias> argument.

Tobias> However, if it's an intercept-only model, it appears
Tobias> to use the intercept as the slope of the abline:

Tobias> mod <- lm(dist ~ 1, data = cars) plot(dist ~ speed,
Tobias> data = cars) abline(reg = mod) # nothing appears

Tobias> This behaves as documented, but might catch
Tobias> someone. Would it be an improvement if this
Tobias> situation was detected so as to plot the appropriate
Tobias> horizontal line, i.e.

Tobias> abline(a = coef(mod), b = 0) ?

Tobias> Would it also be an improvement if for a model like

Tobias> mod2 <- lm(dist ~ 1 + offset(speed), data = cars)

Tobias> abline(reg = mod2) would be equivalent to

Tobias> abline(a = coef(mod2), b = 1) ?

Tobias> For models through the origin, the current function
Tobias> works fine, but one might even consider models
Tobias> through the origin and having the independent
Tobias> variable in an offset() to be fully fool-proof, i.e.

Tobias> abline(a = 0, b = 1)

Tobias> Kind regards, Tobias

Tobias> __
Tobias> R-devel@r-project.org mailing list
Tobias> https://stat.ethz.ch/mailman/listinfo/r-devel

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Wondering about methods (selecting a less specialized method)

2006-12-11 Thread Byron Ellis
Hi All,

I find myself wondering if there is a canonical means of achieving the
multiple-dispatch version of 'super'? Specifically, I have a set of
classes

A, B, X and Y where B extends A

and a method Foo with the signature (X,A,Y) and I'd like to implement
Foo with the signature (X,B,Y) such that it calls Foo_(X,A,Y) and then
does "other stuff." This gets a bit complicated with multiple
inheritance but at the moment the best I can think to do is an
explicit call to selectMethod.

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Wondering about methods (selecting a less specialized method)

2006-12-11 Thread Seth Falcon
"Byron Ellis" <[EMAIL PROTECTED]> writes:

> Hi All,
>
> I find myself wondering if there is a canonical means of achieving the
> multiple-dispatch version of 'super'? Specifically, I have a set of
> classes
>
> A, B, X and Y where B extends A
>
> and a method Foo with the signature (X,A,Y) and I'd like to implement
> Foo with the signature (X,B,Y) such that it calls Foo_(X,A,Y) and then
> does "other stuff." This gets a bit complicated with multiple
> inheritance but at the moment the best I can think to do is an
> explicit call to selectMethod.

I would expect callNextMethod to work in most cases.  Have you tried
that?

setMethod("Foo", c("X", "B", "Y"),
  function(x, b, y) {
  ans <- callNextMethod()
  ## more
  })

+ seth

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Wondering about methods (selecting a less specialized method)

2006-12-11 Thread Byron Ellis
Yup, that does it---I knew there was something but couldn't remember
what it was :-)

On 12/11/06, Seth Falcon <[EMAIL PROTECTED]> wrote:
> "Byron Ellis" <[EMAIL PROTECTED]> writes:
>
> > Hi All,
> >
> > I find myself wondering if there is a canonical means of achieving the
> > multiple-dispatch version of 'super'? Specifically, I have a set of
> > classes
> >
> > A, B, X and Y where B extends A
> >
> > and a method Foo with the signature (X,A,Y) and I'd like to implement
> > Foo with the signature (X,B,Y) such that it calls Foo_(X,A,Y) and then
> > does "other stuff." This gets a bit complicated with multiple
> > inheritance but at the moment the best I can think to do is an
> > explicit call to selectMethod.
>
> I would expect callNextMethod to work in most cases.  Have you tried
> that?
>
> setMethod("Foo", c("X", "B", "Y"),
>   function(x, b, y) {
>   ans <- callNextMethod()
>   ## more
>   })
>
> + seth
>
>


-- 
Byron Ellis ([EMAIL PROTECTED])
"Oook" -- The Librarian

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel