找回密码
 立即注册
查看: 2355|回复: 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-11-25 05:39 , Processed in 0.025352 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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