r - How can I plot the residuals of lm() with ggplot? -
i have nice plot residuals got lm()
model. use plot(model$residuals)
, want have nicer. if try plot ggplot, error message:
ggplot2 doesn't know how deal data of class numeric
fortify no longer recommended , might deprecated according hadley.
you can use broom package similar (better):
library(broom) y <-rnorm(10) x <-1:10 mod <- lm(y ~ x) df <- augment(mod) ggplot(df, aes(x = .fitted, y = .resid)) + geom_point()
Comments
Post a Comment