Reputation: 151
I've seen this error posted elsewhere here, but I've not gotten any of the fixes to work. I'm currently using the built-in "faithful" dataset as part of the r-tutor.com tutorial:
duration = faithful$eruptions
waiting = faithful$waiting
abline(lm(duration ~ waiting))
Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...) :
plot.new has not been called yet
I tried plot.new()
, no luck.
I tried
x <- (duration ~ waiting)
abline(x)
no luck.
I tried re-starting R, no luck. Using 3.0.0 for Windows. Thanks.
Upvotes: 14
Views: 82592
Reputation: 111
Adding a +
after your plot command will work. I worked for me.
plot(y~x) + abline()
credit to Gabriel (2nd comment on the above solution). Though I should post it because usually I do not read the comments and since I am new it would not allow me to thank her. So I thought I should post it as an answer. Thanks, Gabriel. It worked for me as well.
Upvotes: 11
Reputation: 57696
abline
has to be called on an existing plot. You can't call it when nothing has been plotted.
You probably wanted to do this:
plot(duration ~ waiting, data=faithful)
abline(lm(duration ~ waiting, data=faithful))
Upvotes: 22