简体   繁体   English

“int_abline中的错误... plot.new尚未被调用”

[英]“Error in int_abline…plot.new has not been called yet”

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: 我目前正在使用内置的“忠实”数据集作为r-tutor.com教程的一部分:

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. 我试过plot.new() ,没有运气。 I tried 我试过了

x <- (duration ~ waiting)
abline(x)

no luck. 没运气。

I tried re-starting R, no luck. 我试过重新启动R,没有运气。 Using 3.0.0 for Windows. 使用3.0.0 for Windows。 Thanks. 谢谢。

abline has to be called on an existing plot. 必须在现有情节上调用abline 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). 归功于加布里埃尔(上述解决方案的第2条评论)。 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. 它对我也有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM