|
有这么一组代码:
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
|
|