繁体   English   中英

在 R 中使用 lines() 时,行未出现在 plot 上

[英]Line not appearing on plot when using lines() in R

我正在做一个多项式回归,我想 plot 它。

我的代码如下:

创建多项式回归到 1 次

mreg6=lm(user_Score~poly(year_of_Release,1)) 

创建 plot

plot(year_of_Release~user_Score, col='gray')

创建线

lines(sort(year_of_Release),predict(mreg6)[order(year_of_Release)],col='red')

创造传奇

legend('topright',lty=1:2,col=c('red'),c('degree 1'))

当我运行代码时,没有错误,但该线没有出现在图表上。 你们有谁知道我可能做错了什么吗?

我找到了答案:我把 ~ 而不是,放在 plot() 所以它给了我另一个回归。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM