Skip to content

Commit

Permalink
Directly use quantiles from dist_percentile() if available
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchelloharawild committed Sep 8, 2023
1 parent c79f206 commit 46a6622
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion R/dist_percentile.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ format.dist_percentile <- function(x, ...){

#' @export
quantile.dist_percentile <- function(x, p, ...){
stats::approx(x = x[["percentile"]]/100, y = x[["x"]], xout = p)$y
out <- x[["x"]][match(p, x[["percentile"]])]
out[is.na(out)] <- stats::approx(x = x[["percentile"]]/100, y = x[["x"]], xout = p[is.na(out)])$y
out
}

#' @export
Expand Down

0 comments on commit 46a6622

Please sign in to comment.