autoplot.lm | R Documentation |
This uses ggplot2 to replicate the plot functionality for lm in ggplot2 and allow themes.
## S3 method for class 'lm'
autoplot(object, which = c(1:6), mfrow = c(3, 2), ...)
object |
a linear model object from |
which |
which of the tests do we want to display output from |
mfrow |
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: https://librestats.com/2012/06/11/autoplot-graphical-methods-with-ggplot2/
plot.lm
which this function mimics
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.