Allow choosing quantile definition in boxplots #6820
Merged
teunbrand merged 5 commits intotidyverse:mainfrom Mar 18, 2026
Merged
Allow choosing quantile definition in boxplots #6820teunbrand merged 5 commits intotidyverse:mainfrom
teunbrand merged 5 commits intotidyverse:mainfrom
Conversation
Open
3 tasks
Collaborator
|
Thank you for the contribution! The failing tests are unrelated to this PR. |
teunbrand
approved these changes
Mar 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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