Skip to content

Allow choosing quantile definition in boxplots #6820

Merged
teunbrand merged 5 commits intotidyverse:mainfrom
munoztd0:feature/boxplot-quantile-type
Mar 18, 2026
Merged

Allow choosing quantile definition in boxplots #6820
teunbrand merged 5 commits intotidyverse:mainfrom
munoztd0:feature/boxplot-quantile-type

Conversation

@munoztd0
Copy link
Contributor

We need to reproduce SAS boxplot output where percentiles use SAS’s default PCTLDEF = 5, which corresponds to R’s stats::quantile(type = 2). Currently, geom_boxplot()/stat_boxplot() use R’s default quantile definition (type = 7) for hinges/median, and there is no way to change it. This makes it impossible to match SAS results out-of-the-box.

I created a fork with a minimal fix that adds a quantile_type parameter (default 7) to stat_boxplot() (and forwards it from geom_boxplot()), so users can request type = 2 when they need SAS parity.

Although this change is technically small and narrowly scoped, it directly affects which points are classified as outliers and can lead to large, visibly different boxplots; since we’re actively encouraging SAS users to adopt R/ggplot2, supporting SAS’s default percentile definition (PCTLDEF = 5 → R type = 2) would be a valuable, low-risk quality-of-life improvement.

Solves #6819

@teunbrand
Copy link
Collaborator

Thank you for the contribution! The failing tests are unrelated to this PR.

@teunbrand teunbrand merged commit 6f1d988 into tidyverse:main Mar 18, 2026
12 of 13 checks passed
@munoztd0 munoztd0 deleted the feature/boxplot-quantile-type branch March 18, 2026 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants