Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ggpubr::stat_pvalue_manual() fails when fill aesthetic is provided #621

Open
jbengler opened this issue Nov 22, 2024 · 0 comments
Open

ggpubr::stat_pvalue_manual() fails when fill aesthetic is provided #621

jbengler opened this issue Nov 22, 2024 · 0 comments

Comments

@jbengler
Copy link

jbengler commented Nov 22, 2024

Hi @kassambara

ggpubr and rstatix are great packages! I truly admire your dedication and skill in creating such valuable tools for the community!

Expected behavior

The plot should be rendered regardless whether aes(fill) is provided or not.

Actual behavior

Error:
! Problem while computing aesthetics.
ℹ Error occurred in the 2nd layer.
Caused by error:
! object 'supp' not found
Run `rlang::last_trace()` to see where the error occurred.

Steps to reproduce the problem

library(ggpubr)
library(rstatix)

df <- ToothGrowth
df$dose <- as.factor(df$dose)

stat.test <- df %>%
  group_by(dose) %>%
  t_test(len ~ supp) %>%
  add_xy_position(x = "dose")

# this works
ggplot(df, aes(x = dose, y = len, color = supp)) +
  geom_boxplot() +
  stat_pvalue_manual(stat.test)

# this fails
ggplot(df, aes(x = dose, y = len, color = supp, fill = supp)) +
  geom_boxplot() +
  stat_pvalue_manual(stat.test)

# this also fails
ggplot(df, aes(x = dose, y = len, fill = supp)) +
  geom_boxplot() +
  stat_pvalue_manual(stat.test)

session_info()

> devtools::session_info()
─ Session info ───────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.3.1 (2023-06-16)
 os       macOS 15.1
 system   aarch64, darwin20
 ui       RStudio
 language (EN)
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       Europe/Berlin
 date     2024-11-22
 rstudio  2024.09.0+375 Cranberry Hibiscus (desktop)
 pandoc   NAPackages ───────────────────────────────────────────────────────────────────
 package     * version date (UTC) lib source
 abind         1.4-5   2016-07-21 [1] CRAN (R 4.3.0)
 backports     1.5.0   2024-05-23 [1] CRAN (R 4.3.3)
 broom         1.0.6   2024-05-17 [1] CRAN (R 4.3.3)
 cachem        1.1.0   2024-05-16 [1] CRAN (R 4.3.3)
 car           3.1-2   2023-03-30 [1] CRAN (R 4.3.0)
 carData       3.0-5   2022-01-06 [1] CRAN (R 4.3.0)
 cli           3.6.3   2024-06-21 [1] CRAN (R 4.3.3)
 colorspace    2.1-0   2023-01-23 [1] CRAN (R 4.3.0)
 devtools      2.4.5   2022-10-11 [1] CRAN (R 4.3.0)
 digest        0.6.36  2024-06-23 [1] CRAN (R 4.3.3)
 dplyr         1.1.4   2023-11-17 [1] CRAN (R 4.3.1)
 ellipsis      0.3.2   2021-04-29 [1] CRAN (R 4.3.0)
 fansi         1.0.6   2023-12-08 [1] CRAN (R 4.3.1)
 farver        2.1.2   2024-05-13 [1] CRAN (R 4.3.3)
 fastmap       1.2.0   2024-05-15 [1] CRAN (R 4.3.3)
 fs            1.6.4   2024-04-25 [1] CRAN (R 4.3.1)
 generics      0.1.3   2022-07-05 [1] CRAN (R 4.3.0)
 ggplot2     * 3.5.1   2024-04-23 [1] CRAN (R 4.3.1)
 ggpubr      * 0.6.0   2023-02-10 [1] CRAN (R 4.3.0)
 ggsignif      0.6.4   2022-10-13 [1] CRAN (R 4.3.0)
 glue          1.7.0   2024-01-09 [1] CRAN (R 4.3.1)
 gtable        0.3.5   2024-04-22 [1] CRAN (R 4.3.1)
 htmltools     0.5.8.1 2024-04-04 [1] CRAN (R 4.3.1)
 htmlwidgets   1.6.4   2023-12-06 [1] CRAN (R 4.3.1)
 httpuv        1.6.15  2024-03-26 [1] CRAN (R 4.3.1)
 labeling      0.4.3   2023-08-29 [1] CRAN (R 4.3.0)
 later         1.3.2   2023-12-06 [1] CRAN (R 4.3.1)
 lifecycle     1.0.4   2023-11-07 [1] CRAN (R 4.3.1)
 magrittr      2.0.3   2022-03-30 [1] CRAN (R 4.3.0)
 memoise       2.0.1   2021-11-26 [1] CRAN (R 4.3.0)
 mime          0.12    2021-09-28 [1] CRAN (R 4.3.0)
 miniUI        0.1.1.1 2018-05-18 [1] CRAN (R 4.3.0)
 munsell       0.5.1   2024-04-01 [1] CRAN (R 4.3.1)
 pillar        1.9.0   2023-03-22 [1] CRAN (R 4.3.0)
 pkgbuild      1.4.4   2024-03-17 [1] CRAN (R 4.3.1)
 pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.3.0)
 pkgload       1.4.0   2024-06-28 [1] CRAN (R 4.3.3)
 profvis       0.3.8   2023-05-02 [1] CRAN (R 4.3.0)
 promises      1.3.0   2024-04-05 [1] CRAN (R 4.3.1)
 purrr         1.0.2   2023-08-10 [1] CRAN (R 4.3.0)
 R6            2.5.1   2021-08-19 [1] CRAN (R 4.3.0)
 Rcpp          1.0.13  2024-07-17 [1] CRAN (R 4.3.3)
 remotes       2.5.0   2024-03-17 [1] CRAN (R 4.3.1)
 rlang         1.1.4   2024-06-04 [1] CRAN (R 4.3.3)
 rstatix     * 0.7.2   2023-02-01 [1] CRAN (R 4.3.0)
 rstudioapi    0.16.0  2024-03-24 [1] CRAN (R 4.3.1)
 scales        1.3.0   2023-11-28 [1] CRAN (R 4.3.1)
 sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.3.0)
 shiny         1.8.1.1 2024-04-02 [1] CRAN (R 4.3.1)
 stringi       1.8.4   2024-05-06 [1] CRAN (R 4.3.1)
 stringr       1.5.1   2023-11-14 [1] CRAN (R 4.3.1)
 tibble        3.2.1   2023-03-20 [1] CRAN (R 4.3.0)
 tidyr         1.3.1   2024-01-24 [1] CRAN (R 4.3.1)
 tidyselect    1.2.1   2024-03-11 [1] CRAN (R 4.3.1)
 urlchecker    1.0.1   2021-11-30 [1] CRAN (R 4.3.0)
 usethis       2.2.3   2024-02-19 [1] CRAN (R 4.3.1)
 utf8          1.2.4   2023-10-22 [1] CRAN (R 4.3.1)
 vctrs         0.6.5   2023-12-01 [1] CRAN (R 4.3.1)
 withr         3.0.0   2024-01-16 [1] CRAN (R 4.3.1)
 xtable        1.8-4   2019-04-21 [1] CRAN (R 4.3.0)

 [1] /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library

──────────────────────────────────────────────────────────────────────────────
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant