abline() 函数不会在图中绘制直线
abline() function doesn't plot the line in the graph
enter image description hereabline(lm(Qsales ~ Price)) 我正在使用此函数绘制一条线,其中 Qsales 是因变量,Price 是自变量。
在 R studio 中,abline(lm(Qsales ~ Price)) 此命令运行时没有错误,但图中未绘制线条
在线性模型中,响应变量出现在你的“~”之前,这通常是yaxis。参见示例:
fit = lm(mpg ~ wt,data=mtcars)
with(mtcars,plot(wt,mpg))
abline(fit)
因此您需要将其翻转为 abline(lm(Price ~ Qsales))。
enter image description hereabline(lm(Qsales ~ Price)) 我正在使用此函数绘制一条线,其中 Qsales 是因变量,Price 是自变量。 在 R studio 中,abline(lm(Qsales ~ Price)) 此命令运行时没有错误,但图中未绘制线条
在线性模型中,响应变量出现在你的“~”之前,这通常是yaxis。参见示例:
fit = lm(mpg ~ wt,data=mtcars)
with(mtcars,plot(wt,mpg))
abline(fit)
因此您需要将其翻转为 abline(lm(Price ~ Qsales))。