[R] what the problem could be if i am suddenly unable to add abline to the scatter plot?
dwinsemius at comcast.net
Wed May 12 19:37:09 CEST 2010
On May 12, 2010, at 1:30 PM, Erik Iverson wrote:
> David Winsemius wrote:
>> On May 12, 2010, at 11:57 AM, xin wei wrote:
>>> I am doing very regular stuff like the following:
>>> 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)
>>> #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"
> Perhaps all the OP has to do is specify
> abline(reg = fm, col = 4)
Yes. Gets you to the same result:
> x <- 1:10
> y= 5+ x + rnorm(10)
> plot(x, y)
> abline(coef(lm(y ~ x) ) , col="red")
David Winsemius, MD
West Hartford, CT
More information about the R-help