A 'ggplot2' Extension for Geometric Data Analysis

A variety of multivariable data summary statistics and constructions have been proposed, either to generalize univariable analogs or to exploit multivariable properties. Notable among these are the bivariate peelings surveyed by Green (1981, ISBN:978-0-471-28039-2), the bag-and-bolster plots proposed by Rousseeuw &al (1999) , and the minimum spanning trees used by Jolliffe (2002) to represent high-dimensional relationships among data in a low-dimensional plot. Additionally, biplots of singular value--decomposed tabular data, such as from principal components analysis, make use of vectors, calibrated axes, and other representations of variable elements to complement point markers for case elements; see Gabriel (1971) and Gower & Harding (1988) for original proposals. Because they treat the abscissa and ordinate as commensurate or the data elements themselves as point masses or unit vectors, these multivariable tools can be thought of as belonging to geometric data analysis; see Podani (2000, ISBN:90-5782-067-6) for techniques and applications and Le Roux & Rouanet (2005) for foundations. 'gggda' extends Wickham's (2010) layered grammar of graphics with statistical transformation ("stat") and geometric construction ("geom") layers for many of these tools, as well as convenience coordinate systems to emphasize intrinsic geometry of the data.


gggda

Lifecycle:experimental CRAN

{gggda} extends {ggplot2} with coordinate systems, statistical transformations, and geometric constructions useful to the analysis and visualization of multivariate data, including bivariate generalizations of univariate tools and tools designed for geometric data analysis and ordination. It is spun off from and designed to interoperate with {ordr}.

usage

installation

{gggda} is now on CRAN and can be installed in the standard way:

install.packages("gggda")

Or install the development version as follows using {pak}:

pak::pkg_install("corybrunson/gggda")

illustration

Use the new coordinate system to fix the aspect ratio of the plotting window as well as of the coordinates:

# rectangular window (custom aspect ratio)
ggplot(mpg, aes(x = displ, y = hwy)) +
  coord_rect(ratio = .1, window_ratio = 1/2) +
  geom_point()

# square window (unit aspect ratio)
ggplot(mpg, aes(x = cty, y = hwy)) +
  coord_square(xlim = c(0, NA), ylim = c(0, NA)) +
  geom_point()

Some new statistical transformations provide new ways of analyzing bivariate data, for example the depth stat that deploys the {ddalpha} package and mimics the density stat by pairing with the contour geom:

# depth medians and quartiles contours by group
ggplot(mpg, aes(displ, cty, color = drv, fill = drv)) +
  stat_depth(bins = 4) +
  stat_center(fun.ord = depth_median)

Several new geometric constructions have a wide range of uses, including biplots, with two-dimensional errorbars being an underused example:

# centroids with 2-standard deviation bars for both variables
ggplot(mpg, aes(displ, cty, color = factor(cyl))) +
  geom_point() +
  geom_pointranges(fun.data = mean_sdl)

Finally, some stats and geoms are designed to work as pairs, most notably the bagplot layer modeled on the boxplot in {ggplot2}:

# faceted bagplots
ggplot(mpg, aes(displ, hwy, color = drv, fill = drv)) +
  facet_wrap(vars(drv)) +
  stat_bagplot()

acknowledgments

contribute

Any feedback on the package is very welcome! If you encounter confusion or errors, do create an issue, with a minimal reproducible example if feasible. If you have requests, suggestions, or your own implementations for new features, feel free to create an issue or submit a pull request. Please try to follow the contributing guidelines and respect the Code of Conduct.

resources

Development of this package benefitted from the use of equipment and the support of colleagues at UConn Health and at the University of Florida. See the {ordr} repo for detailed acknowledgments.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("gggda")

0.2.0 by Jason Cory Brunson, 3 months ago


https://github.com/corybrunson/gggda, https://corybrunson.github.io/gggda/


Report a bug at https://github.com/corybrunson/gggda/issues


Browse source code at https://github.com/cran/gggda


Authors: Jason Cory Brunson [aut, cre] (ORCID: , Emily Paul [ctb] , John Gracey [aut]


Documentation:   PDF Manual  


GPL-3 license


Imports rlang, tidyr, dplyr, magrittr, scales, labeling, ddalpha

Depends on ggplot2

Suggests gridExtra, MASS, Hmisc, tibble, mlpack, testthat, knitr, rmarkdown


Imported by ordr.


See at CRAN