Skip to content

Commit

Permalink
Fix revdep issue in ggdist relating to transformed missing dists
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchelloharawild committed Sep 17, 2024
1 parent bab60d2 commit ba8e22f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions R/transformed.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ density.dist_transformed <- function(x, at, ...){
cdf.dist_transformed <- function(x, q, ...){
inv <- function(v) suppressWarnings(x[["inverse"]](v))
p <- cdf(x[["dist"]], inv(q), ...)
if(!monotonic_increasing(x[["transform"]], support(x[["dist"]]))) p <- 1 - p
# TODO - remove null dist check when dist_na is structured correctly (revdep temp fix)
if(!is.null(x[["dist"]]) && !monotonic_increasing(x[["transform"]], support(x[["dist"]]))) p <- 1 - p
limits <- field(support(x), "lim")[[1]]
if (!any(is.na(limits))) {
p[q <= limits[1]] <- 0
Expand All @@ -79,7 +80,8 @@ cdf.dist_transformed <- function(x, q, ...){

#' @export
quantile.dist_transformed <- function(x, p, ...){
if(!monotonic_increasing(x[["transform"]], support(x[["dist"]]))) p <- 1 - p
# TODO - remove null dist check when dist_na is structured correctly (revdep temp fix)
if(!is.null(x[["dist"]]) && !monotonic_increasing(x[["transform"]], support(x[["dist"]]))) p <- 1 - p
x[["transform"]](quantile(x[["dist"]], p, ...))
}

Expand Down

0 comments on commit ba8e22f

Please sign in to comment.