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

View source: R/autoplot.lm.R

autoplot.lmR Documentation

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

## S3 method for class 'lm'
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: https://librestats.com/2012/06/11/autoplot-graphical-methods-with-ggplot2/

See Also

plot.lm which this function mimics

Examples

# 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)


eeptools documentation built on June 7, 2023, 5:06 p.m.