@@ -53,15 +53,16 @@ StatBoxplot <- ggproto("StatBoxplot", Stat,
5353
5454 extra_params = c(" na.rm" , " orientation" ),
5555
56- compute_group = function (data , scales , width = NULL , na.rm = FALSE , coef = 1.5 , flipped_aes = FALSE ) {
56+ compute_group = function (data , scales , width = NULL , na.rm = FALSE , coef = 1.5 , flipped_aes = FALSE , quantile.type = 7 ) {
5757 data <- flip_data(data , flipped_aes )
5858 qs <- c(0 , 0.25 , 0.5 , 0.75 , 1 )
5959
6060 if (! is.null(data $ weight )) {
6161 mod <- quantreg :: rq(y ~ 1 , weights = weight , data = data , tau = qs )
6262 stats <- as.numeric(stats :: coef(mod ))
6363 } else {
64- stats <- as.numeric(stats :: quantile(data $ y , qs ))
64+ # Follow base R default (type = 7) unless overridden by user
65+ stats <- as.numeric(stats :: quantile(data $ y , qs , type = quantile.type ))
6566 }
6667 names(stats ) <- c(" ymin" , " lower" , " middle" , " upper" , " ymax" )
6768 iqr <- diff(stats [c(2 , 4 )])
@@ -99,6 +100,8 @@ StatBoxplot <- ggproto("StatBoxplot", Stat,
99100
100101# ' @rdname geom_boxplot
101102# ' @param coef Length of the whiskers as multiple of IQR. Defaults to 1.5.
103+ # ' @param quantile.type An integer between 1 and 9 setting the quantile algorithm
104+ # ' per [`stats::quantile(type)`][stats::quantile]. Defaults to `7`
102105# ' @inheritParams stat_identity
103106# ' @export
104107# ' @eval rd_computed_vars(
0 commit comments