开发者

R will plot but won't draw abline

开发者 https://www.devze.com 2023-04-01 11:01 出处:网络
> head(returnee) [1]1.3936536 -0.67306672.35847252.34773083.28414431.3168157 > head(vixee) [1] 14.75 15.45 17.5开发者_运维百科9 17.74 17.75 18.35
> head(returnee)
[1]  1.3936536 -0.6730667  2.3584725  2.3477308  3.2841443  1.3168157
> head(vixee)
[1] 14.75 15.45 17.5开发者_运维百科9 17.74 17.75 18.35
> class(returnee)
[1] "numeric"
> class(vixee)
[1] "numeric"
> plot(returnee, vixee)
> abline(lm(returnee ~ vixee))

When I run this, it gives the plot, but there is no abline. Any suggestions? Thanks.


It should be abline(lm(vixee ~ returnee)) to match the coordinates of the plot.


In contrast to @AK, I was going to say you had your plot backwards. One or the other ... if the regression is the way you want it (i.e. y~x) then try either

plot(vixee ~ returnee)  ## formula interface, y~x

or

plot(returnee,vixee)    ## standard interface, (x,y)
0

精彩评论

暂无评论...
验证码 换一张
取 消