[英]Line not appearing on plot when using lines() in R
I'm doing a polynomial regression and I want to plot it.我正在做一个多项式回归,我想 plot 它。
My code is the following:我的代码如下:
mreg6=lm(user_Score~poly(year_of_Release,1))
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'))
When I run the code, there is no error but the line does not appear on graph.当我运行代码时,没有错误,但该线没有出现在图表上。 Do any of you know what I might be doing wrong?
你们有谁知道我可能做错了什么吗?
I found my answer: I was putting ~ instead of, in plot() so it was giving me another regression.我找到了答案:我把 ~ 而不是,放在 plot() 所以它给了我另一个回归。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.