This uses ggplot2 to replicate the plot functionality for lm in ggplot2 and allow themes.
# S3 method for lm autoplot(object, which = c(1:6), mfrow = c(3, 2), ...)
a linear model object from lm
lm
which of the tests do we want to display output from
Describes the layout of the resulting function in the plot frames
additional parameters to pass through
A ggplot2 object that mimics the functionality of a plot of linear model.
Modified from: http://librestats.com/2012/06/11/autoplot-graphical-methods-with-ggplot2/
plot.lm which this function mimics
plot.lm
# NOT RUN { # Univariate a <- runif(1000) b <- 7 * a + rnorm(1) mymod <- lm(b~a) autoplot(mymod) # Multivariate data(mpg) mymod <- lm(cty~displ + cyl + drv, data=mpg) autoplot(mymod) # }
Run the code above in your browser using DataLab