[Rd] Surprise with plot.lm()
Peter Dalgaard
pd@me@ @ending from cb@@dk
Tue Oct 9 16:11:43 CEST 2018
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: pd.mes using cbs.dk Priv: PDalgd using gmail.com
More information about the R-devel
mailing list