From pd@me@ @ending from cb@@dk  Tue Oct  9 16:11:43 2018
From: pd@me@ @ending from cb@@dk (Peter Dalgaard)
Date: Tue, 9 Oct 2018 14:11:43 +0000
Subject: [Rd] Surprise with plot.lm()
Message-ID: <96C5F1B6-0217-4C80-8014-D94239C2114B@cbs.dk>

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 at cbs.dk  Priv: PDalgd at gmail.com



[Rd] Surprise with plot.lm()
Peter Dalgaard