Re: R-beta: abline

Thomas Lumley (thomas@biostat.washington.edu)
Fri, 18 Jul 1997 17:08:28 -0700 (PDT)


Date: Fri, 18 Jul 1997 17:08:28 -0700 (PDT)
From: Thomas Lumley <thomas@biostat.washington.edu>
To: Ted Harding <Ted.Harding@nessie.mcc.ac.uk>
Subject: Re: R-beta: abline
In-Reply-To: <m0wpMFX-000Fq6C@Tedistan.annex.umist.ac.uk>

On Sat, 19 Jul 1997, Ted Harding wrote:
> 
> An early Venables example runs
> > {plot(x,y)
> + abline(0,1,lty=3)
> + abline(lsfit(x,y))
> + lines(spline(x,y))}
> 
> which performs the first two OK but then gives error-message
> 
>   Error: no applicable method for "coefficients"

The coef function has no default method, only methods for lm and glm
objects.  You can add

 coefficients.default<- function (model) 
{
        if (is.null(model$coef)) 
                stop("Object has no coefficients")
        model$coef
}

which makes lsfit() work with coef().



Thomas Lumley
------------------------------------------------------+------
Biostatistics		: "Never attribute to malice what  :
Uni of Washington	:  can be adequately explained by  :
Box 357232		:  incompetence" - Hanlon's Razor  :
Seattle WA 98195-7232	:				   :
------------------------------------------------------------

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=