Skip to content

Commit

Permalink
Don't drop empty groups in ggpiestats()
Browse files Browse the repository at this point in the history
closes #935
  • Loading branch information
IndrajeetPatil committed May 17, 2024
1 parent 4442ad2 commit 9f9dbff
Show file tree
Hide file tree
Showing 6 changed files with 268 additions and 2 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ N.B. All statistical analysis in `{ggstatsplot}` is carried out in
read the `NEWS` for that package:
<https://indrajeetpatil.github.io/statsExpressions/news/index.html>

## BUG FIXES

- Empty groups in factors are no longer dropped in `ggpiestats()` and `ggbarstats()` (#935).

# ggstatsplot 0.12.3

## MAJOR CHANGES
Expand Down
2 changes: 1 addition & 1 deletion R/ggbarstats.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ ggbarstats <- function(
if (".counts" %in% names(data)) data %<>% tidyr::uncount(weights = .counts)

# x and y need to be a factor; also drop the unused levels of the factors
data %<>% mutate(across(.cols = everything(), .fns = ~ droplevels(as.factor(.x))))
data %<>% mutate(across(.cols = everything(), .fns = ~ as.factor(.x)))

# TO DO: until one-way table is supported by `BayesFactor`
if (nlevels(pull(data, {{ y }})) == 1L) c(bf.message, proportion.test) %<-% c(FALSE, FALSE)
Expand Down
2 changes: 1 addition & 1 deletion R/ggpiestats.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ ggpiestats <- function(
if (".counts" %in% names(data)) data %<>% tidyr::uncount(weights = .counts)

# x and y need to be a factor; also drop the unused levels of the factors
data %<>% mutate(across(.cols = everything(), .fns = ~ droplevels(as.factor(.x))))
data %<>% mutate(across(.cols = everything(), .fns = ~ as.factor(.x)))
x_levels <- nlevels(pull(data, {{ x }}))
y_levels <- ifelse(test == "one.way", 0L, nlevels(pull(data, {{ y }})))

Expand Down
147 changes: 147 additions & 0 deletions tests/testthat/_snaps/ggcoefstats/meta-analysis-works.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 9f9dbff

Please sign in to comment.