我正在嘗試使用ggplot2
包進行繪圖「理論分位數」X「標準化殘差」。標準化殘差x ggplot2包中的理論分位數圖
我有一個lm()
模型,我用這個情節
library(ggplot2)
model<-lm(mpg~cyl+disp+hp+drat+wt, data=mtcars)
p2<-ggplot(model, aes(qqnorm(.stdresid)[[1]], .stdresid))+geom_point(na.rm = TRUE)
p2<-p2+geom_abline(aes(qqline(.stdresid)))+xlab("Theoretical Quantiles")+ylab("Standardized Residuals")
p2<-p2+ggtitle("Normal Q-Q")+theme_bw()
p2
此代碼,我在這裏https://rpubs.com/therimalaya/43190創立做出的情節,而是返回一個錯誤
Error: Aesthetics must be either length 1 or the same as the data (3110): x
,我不能改變xlab
或ylab
的名稱。我如何解決它?
能否請您做這個重現? –
@ Hack-R我該怎麼做? – Roland
在問題中提供必要的代碼和數據以重現問題。我知道你提供了一個鏈接,但他們希望它在問題中,甚至使用鏈接有點不清楚,因爲你必須尋找你從另一個函數中獲取代碼的位置,找到相應的模型並重命名對象等。 http://stackoverflow.com/help/mcve我這次繼續爲你修復它。 –