Learn R Programming

eeptools (version 0.9.1)

autoplot.lm: A function to replicate the basic plot function for linear models in ggplot2

Description

This uses ggplot2 to replicate the plot functionality for lm in ggplot2 and allow themes.

Usage

"autoplot"(object, which = c(1:6), mfrow = c(3, 2), ...)

Arguments

object
a linear model object from lm
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

Value

A ggplot2 object that mimics the functionality of a plot of linear model.

References

Modified from: http://librestats.com/2012/06/11/autoplot-graphical-methods-with-ggplot2/

See Also

plot.lm which this function mimics

Examples

Run this code
# 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