| Title: | Chauvenet-Type Boxplot |
|---|---|
| Description: | Provides a modified boxplot with a new fence coefficient determined by Lin et al. (2025). The traditional fence coefficient k=1.5 in Tukey's boxplot is replaced by a coefficient based on Chauvenet's criterion, as described in their formula (9). The new boxplot can be implemented in 'base R' with function chau_boxplot(), and in 'ggplot2' with function geom_chau_boxplot(). |
| Authors: | Hongmei Lin [aut], Riquan Zhang [aut], Tiejun Tong [aut, cre] |
| Maintainer: | Tiejun Tong <[email protected]> |
| License: | GPL-3 |
| Version: | 1.0.0 |
| Built: | 2026-05-21 09:27:20 UTC |
| Source: | https://github.com/tiejuntong/chauboxplot |
This package provides a modified boxplot with the new fence coefficient determined by Lin et al. (2025). Specifically, the fence coefficient k=1.5 in Tukey's boxplot has been replaced by the fence coefficient associated with Chauvenet’s criterion in their formula (9). For convenience, we have also provided the chauvenet-type boxplot in both base R with function chau_boxplot(), and in ggplot2 with function geom_chau_boxplot().
Maintainer: Tiejun Tong [email protected]
Authors:
Hongmei Lin [email protected]
Riquan Zhang [email protected]
Hongmei Lin, Riquan Zhang and Tiejun Tong (2025). When Tukey meets Chauvenet: a new boxplot criterion for outlier detection. Journal of Computational and Graphical Statistics, accepted.
Useful links:
This function can be operated the same way as boxplot() in base R, except that the fence coefficient k=1.5 in Tukey's boxplot is replaced by the fence coefficient associated with Chauvenet’s criterion. For details, please refer to formula (9) in Lin et al. (2025).
chau_boxplot(data, group_col = NULL, value_col = NULL, ...)chau_boxplot(data, group_col = NULL, value_col = NULL, ...)
data |
The data frame containing the data. |
group_col |
The column name for grouping data. |
value_col |
The column name for the values to plot. |
... |
Additional arguments passed to the plotting function. |
A Chauvenet-type boxplot in base R.
Hongmei Lin, Riquan Zhang and Tiejun Tong (2025). When Tukey meets Chauvenet: a new boxplot criterion for outlier detection. Journal of Computational and Graphical Statistics, accepted.
# Example 1 chau_boxplot(c(rnorm(1000),5,6)) # Example 2 rate.senior <- c(4.96, 6.30, -5.38, 1.60, 7.24, 5.26, 2.55, 5.96, 3.96, 4.19, 1.88, 4.06, 4.75, 0, 0, 2.5, 2.87, 3.00)/100 chau_boxplot(rate.senior, notch=TRUE)# Example 1 chau_boxplot(c(rnorm(1000),5,6)) # Example 2 rate.senior <- c(4.96, 6.30, -5.38, 1.60, 7.24, 5.26, 2.55, 5.96, 3.96, 4.19, 1.88, 4.06, 4.75, 0, 0, 2.5, 2.87, 3.00)/100 chau_boxplot(rate.senior, notch=TRUE)
This function can be operated the same way as geom_boxplot() in ggplot2, except that the fence coefficient k=1.5 in Tukey's boxplot is replaced by the fence coefficient associated with Chauvenet’s criterion. For details, please refer to formula (9) in Lin et al. (2025).
geom_chau_boxplot( mapping = NULL, data = NULL, geom = "boxplot", position = "dodge2", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, ... )geom_chau_boxplot( mapping = NULL, data = NULL, geom = "boxplot", position = "dodge2", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, ... )
mapping |
Aesthetic mappings created by 'aes()'. |
data |
The data to be displayed in this layer. |
geom |
The geometric object to use for display. |
position |
The position adjustment. |
na.rm |
Logical. Should missing values be removed? |
show.legend |
Logical. Should this layer be included in the legends? |
inherit.aes |
If FALSE, overrides the default aesthetics. |
... |
Other arguments passed to the layer. |
A ggplot2 layer with the Chauvenet-type boxplot.
Hongmei Lin, Riquan Zhang and Tiejun Tong (2025). When Tukey meets Chauvenet: a new boxplot criterion for outlier detection. Journal of Computational and Graphical Statistics, accepted.
# Example 1 library(ggplot2) rate.senior <- c(4.96, 6.30, -5.38, 1.60, 7.24, 5.26, 2.55, 5.96, 3.96, 4.19, 1.88, 4.06, 4.75, 0, 0, 2.5, 2.87, 3.00)/100 year <- 2007:2024 data.senior <- data.frame(x=year, y=rate.senior) C.boxplot.senior <- ggplot(data.senior, aes(y=rate.senior)) + geom_chau_boxplot(fill="purple",width=3) + theme(legend.position = "none") + scale_x_discrete(breaks = NULL) + ylim(-0.057,0.077) + theme(plot.margin = unit(c(0, 0, 0, 0), "inches")) + labs(title="C.boxplot", subtitle="Senior civil servants", x="", y="") print(C.boxplot.senior)# Example 1 library(ggplot2) rate.senior <- c(4.96, 6.30, -5.38, 1.60, 7.24, 5.26, 2.55, 5.96, 3.96, 4.19, 1.88, 4.06, 4.75, 0, 0, 2.5, 2.87, 3.00)/100 year <- 2007:2024 data.senior <- data.frame(x=year, y=rate.senior) C.boxplot.senior <- ggplot(data.senior, aes(y=rate.senior)) + geom_chau_boxplot(fill="purple",width=3) + theme(legend.position = "none") + scale_x_discrete(breaks = NULL) + ylim(-0.057,0.077) + theme(plot.margin = unit(c(0, 0, 0, 0), "inches")) + labs(title="C.boxplot", subtitle="Senior civil servants", x="", y="") print(C.boxplot.senior)