Formula Interface to the Grammar of Graphics
Overview
Provides a formula interface to 'ggplot2' graphics.
layer_factory(), the core function that createsgf_*()functions, has been largely refactored. Most existing behavior
remains unchanged (aside from bug fixes).
- New feature: aesthetics that are normally supplied via the formula can now also be supplied as named arguments using formula syntax, e.g.
gf_point(x = ~var1, y = ~var2, data = df)works likegf_point(var2 ~ var1, data = df). This generalizes to everygf_*function's formula "roles", not justx/y(for examplegf_ribbon(ymin = ~lo, ymax = ~hi, x = ~t, data = df)works likegf_ribbon(lo + hi ~ t, data = df)). If a role is supplied both via a literal formula and as a named argument, the named argument wins and a warning is emitted. - It is now easier to create wrappers around additional stats and geoms. There is a vignette describing how to do so.
Show all changes in 2.0.0Hide the rest of the changes in 2.0.0
- New feature:
layer_factory()gains arequired_packagesargument for
extension-package authors. Naming one or more packages there (e.g.
required_packages = "ggforce") checks, before anything else runs
(including pre), that each is both installed and attached (via
library()), raising an informative error otherwise. This replaces the
hand-written pre-block checks previously used internally, e.g. in
gf_sina(); see the new "Extending ggformula" vignette
(vignette("extending-ggformula")) for details. required_packages is
also recorded in a function's ggformula_spec().
- New feature:
layer_factory()also gainsinstalled_packages, a lighter-weight sibling ofrequired_packagesthat only checks that a package is installed, not that it's attached -- the right fit for functions (built with thelayer_fun =pattern) that call an extension package's function directly viapkg::fun().gf_sf()now usesinstalled_packages = "sf"instead of its hand-writtenprecheck. Also recorded inggformula_spec(). - Attaching a package that imports
ggformula (e.g., mosaic) prevents dependencies of
ggformula from being attached, even when ggformula
is subsequently attached with library(ggformula). This
caused some behavior to break with unclear messaging unless the user explicitly attached dependencies of ggformula (e.g., ggiraph). This should now be fixed via a combination of mechanisms.
- Bug fix:
inherit = FALSEwas silently ignored bygf_*()functions built with an explicitlayer_funnaming ageom_*()constructor rather than the defaultggplot2::layer()-- most visiblygf_violin(), which adoptedlayer_fun = ggplot2::geom_violinin 1.1.0.inherit.aesis now forwarded whenever the layer function declares it, sogf_violin(..., inherit = FALSE)again creates a layer that does not inherit the plot's aesthetics.gf_abline(),gf_hline(), andgf_vline()are unaffected: they are built withinherit.aes = FALSE, matching those geoms' own defaults. - Bug fix: relatedly,
inherit = FALSEwas ignored by everygf_*_interactive()function, since those are built onlayer_interactive()rather thanggplot2::layer().layer_interactive()now accepts and forwardsinherit.aes, so e.g.gf_point_interactive(..., inherit = FALSE)behaves likegf_point(..., inherit = FALSE). When not supplied,inherit.aesis omitted rather than forwarded asNULL, leaving the underlying geom's own default in force. - The vignette on interactive functions has been moved out of the package and only appears on the pkgdown site to reduce the size of the package.
- The tutorials have been converted to webr.
- Bug fix:
gf_hline(),gf_vline(),gf_abline(), and similar functions used withdata = NA(i.e., with all values supplied directly rather than from a data frame) could error or silently pass duplicated/incorrect arguments (such asposition) down to the underlying geom, because argument names shared with ggplot2'sgeom_*()/stat_*()constructors (data,mapping,position,show.legend,inherit.aes,geom,stat) were incorrectly treated as generic settable parameters. This also fixed a related failure in somegf_*_interactive()layers (e.g.gf_jitter_interactive(width = ...)) that could error with "Bothpositionandwidth/heightwere supplied." - Bug fix: replaced remaining internal use of the removed/deprecated
aes_string()(used only in thedata = NAcode path above) with a tidy-eval equivalent. - Internal refactor: the body of the function created by
layer_factory()(used to build everygf_*function) has been decomposed into small, individually documented helper functions, one per stage of the "formula -> ggplot2 layer" pipeline. This is intended to make the code easier to read, test, and extend; no behavior changes are intended from this refactor alone. - Internal: every function created by
layer_factory()now records an explicit, documented specification (retrieved with the newggformula_spec()) of thegeom,stat,position,aes_form,extras,pre,aesthetics,inherit.aes,check.aes,required_packages, andinstalled_packagesit was built with.interactive_layer_factory()now reads that single documented record instead of scraping several loosely-related bindings out of agf_*function's environment, and extension packages can use it too.
From NEWS.md in the release
Install
Health
- OK13 OK2026-09-16
- NOTE12 OK, 1 NOTE2026-07-11
- OK13 OK2026-06-09
- ERROR12 OK, 1 ERROR2026-06-08
- OK13 OK2026-05-02
Show 2 earlier changesHide 2 earlier changes
- ERROR11 OK, 1 ERROR2026-04-25
- NOTE11 OK, 3 NOTE2026-03-10
Documentation
- Help pages
- 113 (2 internal)includes a package overview page
- Examples that run
- 99%100 run in a plain check (1 of them under a condition) · 1 never run
- Exported functions with examples
- 91%
- Documented parameters
- 91%
- Return-value docs
- 81%
- Help pages citing references
- 3%
Downloads
Repository
- PRs merged (all time)
- 100%
- Median days to close, 50 most recently updated closed issues
- 76
- Median days to close, 50 most recently updated closed PRs
- 55
Stars over time
Forks over time
Releases over time
Issues over time
PRs over time
Commits over time
Commit identities over time
13 development-tooling and community-health practices detected across 6 families in the upstream repository
Checks run against github.com/projectmosaic/ggformula on 2026-10-18.
The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel
GitHub Pages site last deployed 2026-09-10
Show all practicesHide 2 practices
This repository shows signs of AI coding tools.
- Claude Codefirst seen 2026-07-01Named in .Rbuildignore: .claudeNamed in .gitignore: .claudeCommits: at least 12 crediting it in the message
- Claude CodePull requests: 1 from outside contributors, first on 2026-07-02, 1 from forks
- Claude Sonnet 511 commits · Sep 2026
- Claude Sonnet 4.61 commit · Jul 2026
Dependencies
Installing ggformula adds 73 packages (37 with compiled code, 61 MB of source tarballs). Heaviest: stringi 11 MB, ggplot2 6.0 MB, bslib 5.6 MB.
Code & Tests
Datasets
People & History
Maintainer since 0.4.0 (2017)
Pick two releases to compare their code metrics.
- 2.0.0Latest
- RR 4.6.0 released · 2026-04-24
- 1.0.12026-01-17 · diff ↗
- 1.0.02025-10-06 · diff ↗ ·
added 50 exports
gf_abline_interactive, gf_area_interactive, gf_bar_interactive, gf_bin2d_interactive, gf_bin_2d, gf_bin_2d_interactive, gf_boxplot_interactive, gf_col_interactive, gf_contour_filled_interactive, gf_contour_interactive, gf_count_interactive, gf_crossbar_interactive, gf_curve_interactive, gf_density2d_filled_interactive, gf_density2d_interactive, gf_density_2d_filled_interactive, gf_density_2d_interactive, gf_density_interactive, gf_dotplot_interactive, gf_errorbar_interactive, gf_facet_grid_interactive, gf_facet_wrap_interactive, gf_freqpoly_interactive, gf_girafe, gf_hex_interactive, gf_histogram_interactive, gf_hline_interactive, gf_jitter_interactive, gf_label_interactive, gf_labeller_interactive and 20 more - 0.12.2
- RR 4.5.0 released · 2025-04-11
- RR 4.4.0 released · 2024-04-24
- 0.12.0
- RR 4.3.0 released · 2023-04-21
- 0.10.42023-04-11 · diff ↗
- 0.10.22022-09-01 · diff ↗
- RR 4.2.0 released · 2022-04-22
- RR 4.1.0 released · 2021-05-18
- 0.10.12021-01-13 · diff ↗ ·
added 17 exports
var_label<-, get_variable_labels, gf_contour_filled, gf_dens2, gf_density2d_filled, gf_density_2d_filled, gf_density_ridgeline_gradient, gf_density_ridges, gf_density_ridges2, gf_density_ridges_gradient, gf_plot, gf_relabel, gf_ridgeline, percs_by_group, props_by_group, set_variable_labels, var_label - RR 4.0.0 released · 2020-04-24
- 0.9.42020-03-04 · diff ↗
Show 14 earlier eventsHide 14 earlier events
- 0.9.3
- 0.9.2
- RR 3.6.0 released · 2019-04-26
- 0.9.12019-01-12 · diff ↗
- 0.9.02018-08-03 · diff ↗ ·
added 21 exports
gf_barh, gf_bin2d, gf_boxploth, gf_colh, gf_countsh, gf_crossbarh, gf_dhistogramh, gf_fun2d, gf_fun_2d, gf_fun_contour, gf_fun_tile, gf_function2d, gf_function_2d, gf_function_contour, gf_function_tile, gf_histogramh, gf_linerangeh, gf_percentsh, gf_pointrangeh, gf_propsh, gf_violinh - 0.8.0
- 0.7.0
- RR 3.5.0 released · 2018-04-23
- 0.6.2
- 0.6.1
- 0.6
- 0.52017-07-24 · diff ↗ ·
added 19 exports
GeomLm, StatAsh, StatLm, StatQqline, StatSpline, geom_ash, geom_lm, geom_spline, gf_ash, gf_blank, gf_dhistogram, gf_dist, gf_qqline, gf_qqstep, makeFun, stat_ash, stat_lm, stat_qqline, stat_spline - 0.4.02017-06-22
- RR 3.4.0 released · 2017-04-21
Package metadata
- First published
- 2017-06-22
- Total releases
- 20 / 9 yrs
- License
- MIT + file LICENSE OSI
- Minimum R
- ≥ 4.1
- Bundled data
- 1.3 KB / 1 file
- Download size
- 6.0 MB
Cite
Cite this package
Run in R for the authors' preferred citation:
citation("ggformula")This package has no citation file, so citation() returns this entry built from DESCRIPTION.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-22, which the citation names so these numbers can be found later. More on citing and the projects behind them.