[R] what the problem could be if i am suddenly unable to add abline to the scatter plot?

Erik Iverson eriki at ccbr.umn.edu
Wed May 12 19:30:16 CEST 2010

David Winsemius wrote:
> On May 12, 2010, at 11:57 AM, xin wei wrote:
>> I am doing very regular stuff like the following:
>> attach(wtana)
>> fm<- lm(Body.Wt.on.SD1~Heart.Wt, data=wtana)
>> #fm<- lm(wtana$Body.Wt.on.SD1~wtana$Heart.Wt)
>> lrf<- loess(Body.Wt.on.SD1~Heart.Wt, wtana)
>> #lrf<- loess(wtana$Body.Wt.on.SD1~wtana$Heart.Wt)
>> plot(Body.Wt.on.SD1,Heart.Wt)
>> #plot(wtana$Body.Wt.on.SD1,wtana$Heart.Wt)
>> #lines(spline(Heart.Wt,fitted(lrf)), col=2)
>> abline(fm, col=4)
>> however, the abline just refuse to to show up in the scatter cloud.
>> Does anyone has clue?
> I don't know that abline has a method for lm objects.
>  > methods(abline)
> no methods were found
> Warning message:
> In methods(abline) : function 'abline' appears not to be generic

I haven't read this thread, so don't know what the issue is.  abline 
does not have a method for 'lm' objects, but it does allow you to pass 
an object with a coef method (e.g., an lm object) to the "reg" parameter.

Perhaps all the OP has to do is specify

abline(reg = fm, col = 4)


More information about the R-help mailing list