【问题标题】:abline() function doesn't plot the line in the graphabline() 函数不会在图中绘制线条
【发布时间】:2019-12-14 10:41:28
【问题描述】:

enter image description hereabline(lm(Qsales ~ Price)) 我正在使用此函数绘制一条线,其中 Qsales 是因变量,Price 是自变量。 在 R studio 中, abline(lm(Qsales ~ Price)) 此命令运行没有错误,但图中未绘制线

【问题讨论】:

    标签: r rstudio regression linear-regression


    【解决方案1】:

    在线性模型中,响应变量位于您的 "~" 之前,这通常是 y 轴。见例子:

    fit = lm(mpg ~ wt,data=mtcars)
    with(mtcars,plot(wt,mpg))
    abline(fit)
    

    所以你需要把它翻转到 abline(lm(Price ~ Qsales))。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-05
      • 2017-06-12
      • 1970-01-01
      • 1970-01-01
      • 2022-12-03
      • 1970-01-01
      • 1970-01-01
      • 2020-01-02
      相关资源
      最近更新 更多