Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Error in int_abline...plot.new has not been called yet"

Tags:

plot

r

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.

like image 271
user2844894 Avatar asked Oct 08 '13 02:10

user2844894


2 Answers

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))
like image 111
Hong Ooi Avatar answered Nov 08 '22 12:11

Hong Ooi


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.

like image 9
Steven Lawrence Avatar answered Nov 08 '22 13:11

Steven Lawrence