Skip to content

Commit

Permalink
merge pr #529: address warnings when shading zero area
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpcouch authored Mar 25, 2024
2 parents e6212f3 + 18fdf9e commit 2c5e800
Show file tree
Hide file tree
Showing 32 changed files with 203 additions and 3,567 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

* The aliases `p_value()` and `conf_int()`, first deprecated 6 years ago, now
return an error (#530).

* Addresses ggplot2 warnings when shading p-values for test statistics
that are outside of the range of the generated distribution (#528).

# infer v1.0.6

Expand Down
8 changes: 8 additions & 0 deletions R/shade_p_value.R
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ shade_p_value_term <- function(plot, obs_stat, direction,
segment_args <- c_dedupl(
# Not overwritable arguments
list(
# Address length-1 aesthetics warning by providing geom-specific data (#528)
data = data.frame(obs_stat = obs_stat),
# Here `aes()` is needed to force {ggplot2} to include segment in the plot
mapping = aes(x = obs_stat, xend = obs_stat, y = 0, yend = Inf),
color = color,
Expand Down Expand Up @@ -346,6 +348,12 @@ hist_area <- function(data, obs_stat, direction, yval) {
right = c(obs_stat, x_extra[x_extra > obs_stat])
)

# if area will have area 0, return 0-length tibble to trigger
# `ggplot:::empty()` edge case (#528)
if (length(x_grid) == 1) {
return(tibble::tibble(x = numeric(0), y = numeric(0), dir = character(0)))
}

tibble::tibble(x = x_grid, y = curve_fun(x_grid), dir = direction)
}

Expand Down
99 changes: 0 additions & 99 deletions tests/testthat/_snaps/shade_p_value/pval-both-both.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 2c5e800

Please sign in to comment.