Surprise with plot.lm()

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Surprise with plot.lm()

R devel mailing list
Here's a silly little stunt:

> Y <- rexp(10) ; x <- 1:10
> plot(lm(I(Y^.3)~x))
Hit <Return> to see next plot:
Hit <Return> to see next plot:
Error: $ operator is invalid for atomic vectors

The root cause is that the "AsIs" class lingers on the intercept passed to abline() via qqline(), so abline sees that it has been passed an object and uses coef() and coef.default() looks for object$coefficients, and... poof!

The immediate workaround is just to drop the I(), but as I() is frequently needed on the right hand side of formulas, this looks like a rather easy mistake to make, so it might be worth fixing, but how?

--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: [hidden email]  Priv: [hidden email]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel