设为首页收藏本站获取积分奖励

R语言中文网

 找回密码
 立即注册
查看: 1192|回复: 0

abline的问题

[复制链接]
发表于 2021-2-8 17:31:53 | 显示全部楼层 |阅读模式
有这么一组代码:
require(stats)
reg<-lm(dist ~ speed, data = cars)
coeff=coefficients(reg)
# equation of the line :
eq = paste0("y = ", round(coeff[2],1), "*x ", round(coeff[1],1))
# plot
plot(cars, main=eq)
abline(reg, col="blue")

一起运行是能运行处结果的,但是,为什么每一行分别运行,abline那里就报错了?为什么提示是plot未被调用?
Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...) : plot.new has not been called yet


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Archiver|R语言中文网    

GMT+8, 2024-5-20 14:50 , Processed in 0.027471 second(s), 19 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表