R-beta: abline

Ted Harding (Ted.Harding@nessie.mcc.ac.uk)
Sat, 19 Jul 1997 00:15:45 +0100 (GMT+0100)


Message-Id: <m0wpMFX-000Fq6C@Tedistan.annex.umist.ac.uk>
From: Ted.Harding@nessie.mcc.ac.uk (Ted Harding)
Subject: R-beta: abline
To: r-help@stat.math.ethz.ch (R Help List)
Date: Sat, 19 Jul 1997 00:15:45 +0100 (GMT+0100)

Hi Folks,

R seems to have reached the stage of being quite usable for serious work.
Congratulations on impressive development!

So I've pulled 0.49, palyed with it, joined the lists. I expect to have
quite a few questions.

Here's the first (doesn't seem to be in the archives).

As a try at seeing what differences there may be between R and S, since
the R documentation isn't perfect yet, I've been trying out examples from
Bill Venables's Notes on S and Brian Ripley's Intro to S-plus.

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"

which arises from the line "abline(lsfit(x,y))"; the last ("spline") line
is then not performed. However, all works fine if the "lsfit" line is
replaced by

+ abline(lsfit(x,y)$coef)}

and then the rest is also OK.

The error message suggests awareness of something that ought to be there
but isn't. I've had a look at the output of "lsfit(x,y)" without seeing
anything untoward, since the only bit that refers to coefficients is

$coef
  Intercept           X 
-0.03502458  1.01352108 

which is the same as the output from "lsfit(x,y)$coef". Why does it work
when "forced" in this way but not when implicitly left to abline?

One possible clue is
> abline(coef=lsfit(x,y))
Error: object cannot be coerced to vector type

> abline(coef=lsfit(x,y)$coef)  

[succeeds]

Comments gratefully rceived!

Best wishes to all,
Ted.                                    (Ted.Harding@nessie.mcc.ac.uk)
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=