【发布时间】:2018-11-14 14:57:53
【问题描述】:
首先,我根据clean_sales 中的数据拟合模型并将其传递给对象fit_num_var,但随后我很难将其制成图表以可视化拟合值和学生化残差。我的代码如下:
#Outliers
attach(clean_sales)
fit_num_var <- lm(SalePrice ~ ResidentialUnits + CommercialUnits +
YearBuilt + TotalUnits + LandSquareFeet + GrossSquareFeet)
fit_num_var
ggplot(fit_num_var, aes(x=as.vector(fitted.values), y=as.vector(residuals))) +
geom_point() + geom_line() + xlab("Fitted Values") + ylab("Studentized Residuals")
错误信息是:
as.vector(x, mode) 中的错误:无法将“闭包”类型强制转换为“any”类型的向量
请告诉我应该如何解决这个问题。非常感谢!
【问题讨论】:
-
欢迎来到 Stack Overflow!您能否通过分享您的数据样本来重现您的问题,以便其他人可以提供帮助(请不要使用
str()、head()或屏幕截图)?您可以使用reprex和datapasta包来帮助您。另见Help me Help you & How to make a great R reproducible example? -
希望你听说过ggResidpanel goodekat.github.io/ggResidpanel-tutorial/tutorial.html。