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.
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))
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With