在将控制变量的值设置为特定数字之后,我试图在因变量上预测独立变量的值,然后绘制结果。
通过使用预测,我可以得到看似合理的结果,但是ggplot不允许我将其绘制为散点图,错误代码为:“ data
必须是数据帧,或者其他可强制执行的对象fortify()
,而不是数字向量”
我使用以下预测代码:
lm_graph1 <- predict(lm1,minority = 0, age = 48.37, female = 0, onecredit = 0,nnenglish = 0)
和此ggplot代码:
graph1 <-ggplot(lm_graph1, aes( x = beauty, y = course_eval )) +
geom_point( color = "darkblue")+
geom_smooth(method="loess", se=F) +
labs( subtitle = "Evaluations and beauty",
y = "Course evaluation",
x = "Beauty rating",
title = "Graph 1")
这给了我这个错误。有人知道问题出在哪里,如何绘制结果?