Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hotelling’s T² Ellipses and Outlier Detection for ggplot2

R-CMD-check Codecov test coverage

Here are a few examples of plots you can create with gghotelling:

Features:

  • Classical Hotelling and data ellipses with geom_hotelling()
  • Robust Hotelling ellipses using MCD estimator with robust=TRUE
  • Hotelling confidence ellipses for group means with type="t2mean"
  • Kernel density coverage contours with geom_kde()
  • Outlier detection with outliers()
  • Outlier visualization with stat_outliers() and plot_outliers()
  • Convex hulls with geom_hull()
  • Bagplots with geom_bag()
  • Autoplot and autolayer methods for prcomp objects

See the vignette for more details.

Installation

You can install the development version of gghotelling from GitHub with:

# install.packages("pak")
pak::pak("january3/gghotelling")

Minimal Example

The package defines a new geom, geom_hotelling(), which can be used to add Hotelling ellipses to ggplot2 scatter plots. Here are two examples of usage:

library(ggplot2)
library(gghotelling)

pca <- prcomp(iris[, 1:4], scale.=TRUE)
df <- cbind(iris, pca$x)

# minimum example
p1 <- ggplot(df, aes(PC1, PC2, color=Species)) +
  geom_hotelling() +
  geom_point()

# set custom CI/coverage level
p2 <- ggplot(df, aes(PC1, PC2, color=Species)) +
  geom_hotelling(alpha=0.1, aes(fill = Species), level=.99) +
  geom_point()

cowplot::plot_grid(p1, p2, ncol=2)

AI and other tools disclosure

I used LLM modes to a) detect bugs, spelling errors, clerical mistakes and other deficiencies in the code and b) better understand the ggplot2 specific code (especially after_stat()).

Furthermore, I used devtools, checktor and covr.

About

❗ This is a read-only mirror of the CRAN R package repository. gghotelling — Hotelling's T² Ellipses and Outlier Detection for 'ggplot2'. Homepage: https://github.com/january3/gghotelling/https://january3.github.io/gghotelling/

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages