Applr: Tools for Visualizing and Explaining Linear Models
Source:R/Applr-package.R
Applr-package.RdApplr is a small R package that makes it easy to visualize slices of higher-dimensional linear models and to present model equations clearly. It includes base R and ggplot2 helpers, plus an interactive 3D view for models with two predictors.
Details
Core capabilities:
2D slices of multi-variable models in base graphics
ggplot2 layer for plotting model slices across facets
Interactive 3D scatter with fitted surface (two predictors)
Quick text/LaTeX equations from lm() objects
Main functions
autoplot:
autoplot.lmBase graphics:
slice_2d,add_slice_2dggplot2 layer:
geom_slice(built onStatSliceandGeomSlice)ggplot2 labeling:
geom_slice_text,geom_slice_subtitle,geom_slice_caption3D visualization:
scatter_3dEquations:
lm_equation,lm_latex
Quick start
Fit a model, then see it in one call:
Or build the plot yourself with a geom_slice() layer:
library(ggplot2)
model <- lm(hwy ~ displ * drv + cyl, data = mpg)
ggplot(mpg, aes(displ, hwy, color = drv)) +
geom_point() +
geom_slice(model, band = TRUE) +
geom_slice_text() +
geom_slice_subtitle()See also
Function help pages:
?slice_2d,?geom_slice,?scatter_3d,?lm_equation,?lm_latexThe package README for a brief tour
Author
Maintainer: James Beeson jamesbeeson01@gmail.com
Authors:
Cameron McClellan cameron.m.mcclellan@gmail.com
Other contributors:
Garrett Saunders saundersg@byui.edu [thesis advisor]