ggmodel is an R package aimed at transforming model outputs from base R into beautiful 2D visualizations using ggplot2. π
Currently, the package is in beta and includes one core function β ggsurface
β designed to generate 2D surface plots from linear, generalized linear, and loess models.
lm
, glm
, and loess
objects. Install the development version of ggmodel from GitHub:
# Install remotes package if not already installed
install.packages("remotes")
# Install ggmodel (beta)
remotes::install_github("wilsonfrantine/ggmodel")
Hereβs what you can do with the current version of ggmodel
:
# Load necessary libraries
library(ggmodel)
# Fit a basic linear model
model <- lm(mpg ~ wt + hp, data = mtcars)
# Visualize model surface
ggsurface(model, x.var = "wt", y.var = "hp", legend.title = "Miles per Gallon")
The plot will show how weight (wt
) and horsepower (hp
) interact to influence miles per gallon (mpg
).
π For a full tutorial, visit the ggmodel project page.
ggsurface()
β The Core of ggmodelggsurface
is a versatile function that generates 2D model surface plots for regression models in R.
Supported Models:
- lm
β Linear Models
- glm
β Generalized Linear Models
- loess
β Local Polynomial Regression
Key Arguments:
- m
β Model object (lm
, glm
, or loess
).
- x.var
β Name of the predictor variable for the x-axis.
- y.var
β Name of the predictor variable for the y-axis.
- legend.title
β Title for the legend (default: response variable name).
- xgrid.size
/ ygrid.size
β Grid resolution (default: 15).
- low.col
/ high.col
β Gradient colors for low and high surface values.
- n.bins
β Number of bins for discretizing the surface (default: 10).
- scale.type
β Prediction scale (link
or response
).
π§ Although ggmodel currently focuses on surface plots, future updates will include:
- π Coefficient Plots β Visualize model coefficients with confidence intervals.
- π Residual Analysis β Expanded diagnostic plots for GLMs.
- π§© Support for More Models β Compatibility with gam
(Generalized Additive Models) and mixed models.
Since ggmodel is in early development, contributions are encouraged and highly appreciated!
This project is licensed under the GPL License.
ggmodel is in beta. While functional, the package currently offers limited features. Expect new additions soon!
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.