IndrajeetPatil / ggstatsplot

Enhancing {ggplot2} plots with statistical analysis πŸ“ŠπŸ“£
https://indrajeetpatil.github.io/ggstatsplot/
GNU General Public License v3.0
1.99k stars 184 forks source link

[ggbetweenstats] mtcars example: BA ($caption_data) not reported #879

Closed lxsteiner closed 1 year ago

lxsteiner commented 1 year ago

I simply ran the example on https://indrajeetpatil.github.io/ggstatsplot/reference/ggbetweenstats.html but the result is different from what is reported there.

> library(ggstatsplot)
You can cite this package as:
     Patil, I. (2021). Visualizations with statistical details: The 'ggstatsplot' approach.
     Journal of Open Source Software, 6(61), 3167, doi:10.21105/joss.03167
> set.seed(123)
> library(PMCMRplus)
> p <- ggbetweenstats(mtcars, am, mpg)
> p
> extract_stats(p)
$subtitle_data
# A tibble: 1 Γ— 18
  term  group mean.group1 mean.group2 statistic df.error p.value method                  alternative effectsize
  <chr> <chr>       <dbl>       <dbl>     <dbl>    <dbl>   <dbl> <chr>                   <chr>       <chr>     
1 mpg   am           17.1        24.4     -3.77     18.3 0.00137 Welch Two Sample t-test two.sided   Hedges' g 
  estimate conf.level conf.low conf.high conf.method conf.distribution n.obs expression
     <dbl>      <dbl>    <dbl>     <dbl> <chr>       <chr>             <int> <list>    
1    -1.35       0.95    -2.17    -0.512 ncp         t                    32 <language>

$caption_data
NULL

$pairwise_comparisons_data
NULL

$descriptive_data
NULL

$one_sample_data
NULL

$tidy_data
NULL

$glance_data
NULL

Seems like no complementary Bayesian analysis is done since nothing is reported in $caption_data and I also don't see the corresponding report on the plot. image

Same with iris example:

> q <- ggbetweenstats(
+     data  = iris,
+     x     = Species,
+     y     = Sepal.Length,
+     title = "Distribution of sepal length across Iris species"
+ )
> q
> extract_stats(q)
$subtitle_data
# A tibble: 1 Γ— 14
  statistic    df df.error  p.value method                                                   effectsize estimate
      <dbl> <dbl>    <dbl>    <dbl> <chr>                                                    <chr>         <dbl>
1      139.     2     92.2 1.51e-28 One-way analysis of means (not assuming equal variances) Omega2        0.743
  conf.level conf.low conf.high conf.method conf.distribution n.obs expression
       <dbl>    <dbl>     <dbl> <chr>       <chr>             <int> <list>    
1       0.95    0.671         1 ncp         F                   150 <language>

$caption_data
NULL

$pairwise_comparisons_data
# A tibble: 3 Γ— 9
  group1     group2     statistic  p.value alternative distribution p.adjust.method test         expression
  <chr>      <chr>          <dbl>    <dbl> <chr>       <chr>        <chr>           <chr>        <list>    
1 setosa     versicolor     14.9  5.72e-10 two.sided   q            Holm            Games-Howell <language>
2 setosa     virginica      21.8  0        two.sided   q            Holm            Games-Howell <language>
3 versicolor virginica       7.96 5.58e- 7 two.sided   q            Holm            Games-Howell <language>

$descriptive_data
NULL

$one_sample_data
NULL

$tidy_data
NULL

$glance_data
NULL

Were the default settings changed so it's not reported as a complementary analysis anymore or is something missing on my side? Thanks.

IndrajeetPatil commented 1 year ago

Hmm, I can't reproduce this behaviour:

library(ggstatsplot)
p <- ggbetweenstats(mtcars, am, mpg)
extract_stats(p)
#> $subtitle_data
#> # A tibble: 1 Γ— 18
#>   term  group mean.group1 mean.group2 statistic df.error p.value
#>   <chr> <chr>       <dbl>       <dbl>     <dbl>    <dbl>   <dbl>
#> 1 mpg   am           17.1        24.4     -3.77     18.3 0.00137
#>   method                  alternative effectsize estimate conf.level conf.low
#>   <chr>                   <chr>       <chr>         <dbl>      <dbl>    <dbl>
#> 1 Welch Two Sample t-test two.sided   Hedges' g     -1.35       0.95    -2.17
#>   conf.high conf.method conf.distribution n.obs expression
#>       <dbl> <chr>       <chr>             <int> <list>    
#> 1    -0.512 ncp         t                    32 <language>
#> 
#> $caption_data
#> # A tibble: 1 Γ— 16
#>   term       effectsize      estimate conf.level conf.low conf.high    pd
#>   <chr>      <chr>              <dbl>      <dbl>    <dbl>     <dbl> <dbl>
#> 1 Difference Bayesian t-test    -6.49       0.95    -10.1     -2.75  1.00
#>   prior.distribution prior.location prior.scale  bf10 method         
#>   <chr>                       <dbl>       <dbl> <dbl> <chr>          
#> 1 cauchy                          0       0.707  86.6 Bayesian t-test
#>   conf.method log_e_bf10 n.obs expression
#>   <chr>            <dbl> <int> <list>    
#> 1 ETI               4.46    32 <language>
#> 
#> $pairwise_comparisons_data
#> NULL
#> 
#> $descriptive_data
#> NULL
#> 
#> $one_sample_data
#> NULL
#> 
#> $tidy_data
#> NULL
#> 
#> $glance_data
#> NULL

Created on 2023-09-06 with reprex v2.0.2

Session info ``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.3.1 (2023-06-16) #> os macOS Ventura 13.4.1 #> system aarch64, darwin20 #> ui X11 #> language (EN) #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz Europe/Berlin #> date 2023-09-06 #> pandoc 3.1.6.1 @ /usr/local/bin/ (via rmarkdown) #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date (UTC) lib source #> BayesFactor 0.9.12-4.4 2022-07-05 [1] CRAN (R 4.3.0) #> bayestestR 0.13.1.2 2023-07-03 [1] https://easystats.r-universe.dev (R 4.3.1) #> cli 3.6.1 2023-03-23 [1] CRAN (R 4.3.0) #> coda 0.19-4 2020-09-30 [1] CRAN (R 4.3.0) #> codetools 0.2-19 2023-02-01 [1] CRAN (R 4.3.1) #> colorspace 2.1-0 2023-01-23 [1] CRAN (R 4.3.0) #> correlation 0.8.5 2023-08-21 [1] https://easystats.r-universe.dev (R 4.3.1) #> datawizard 0.8.0.8 2023-08-30 [1] https://easystats.r-universe.dev (R 4.3.1) #> digest 0.6.33 2023-07-07 [1] CRAN (R 4.3.0) #> dplyr 1.1.3 2023-09-03 [1] CRAN (R 4.3.0) #> effectsize 0.8.5 2023-08-09 [1] CRAN (R 4.3.0) #> emmeans 1.8.8 2023-08-17 [1] CRAN (R 4.3.1) #> estimability 1.4.1 2022-08-05 [1] CRAN (R 4.3.0) #> evaluate 0.21 2023-05-05 [1] CRAN (R 4.3.0) #> fansi 1.0.4 2023-01-22 [1] CRAN (R 4.3.0) #> fastmap 1.1.1 2023-02-24 [1] CRAN (R 4.3.0) #> fs 1.6.3 2023-07-20 [1] CRAN (R 4.3.0) #> generics 0.1.3 2022-07-05 [1] CRAN (R 4.3.0) #> ggplot2 3.4.3 2023-08-14 [1] CRAN (R 4.3.1) #> ggrepel 0.9.3 2023-02-03 [1] CRAN (R 4.3.0) #> ggstatsplot * 0.12.0 2023-06-02 [1] local #> glue 1.6.2 2022-02-24 [1] CRAN (R 4.3.0) #> gtable 0.3.4 2023-08-21 [1] CRAN (R 4.3.1) #> htmltools 0.5.6 2023-08-10 [1] CRAN (R 4.3.1) #> insight 0.19.3.3 2023-08-30 [1] https://easystats.r-universe.dev (R 4.3.1) #> knitr 1.43 2023-05-25 [1] CRAN (R 4.3.0) #> lattice 0.21-8 2023-04-05 [1] CRAN (R 4.3.1) #> lifecycle 1.0.3 2022-10-07 [1] CRAN (R 4.3.0) #> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.3.0) #> MASS 7.3-60 2023-05-04 [1] CRAN (R 4.3.1) #> Matrix 1.6-1 2023-08-14 [1] CRAN (R 4.3.0) #> MatrixModels 0.5-2 2023-07-10 [1] CRAN (R 4.3.0) #> multcomp 1.4-25 2023-06-20 [1] CRAN (R 4.3.0) #> munsell 0.5.0 2018-06-12 [1] CRAN (R 4.3.0) #> mvtnorm 1.2-3 2023-08-25 [1] CRAN (R 4.3.0) #> paletteer 1.5.0 2022-10-19 [1] CRAN (R 4.3.0) #> parameters 0.21.1.2 2023-06-27 [1] https://easystats.r-universe.dev (R 4.3.1) #> patchwork 1.1.3 2023-08-14 [1] CRAN (R 4.3.1) #> pbapply 1.7-2 2023-06-27 [1] CRAN (R 4.3.0) #> pillar 1.9.0 2023-03-22 [1] CRAN (R 4.3.0) #> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.3.0) #> purrr 1.0.2 2023-08-10 [1] CRAN (R 4.3.0) #> R.cache 0.16.0 2022-07-21 [1] CRAN (R 4.3.0) #> R.methodsS3 1.8.2 2022-06-13 [1] CRAN (R 4.3.0) #> R.oo 1.25.0 2022-06-12 [1] CRAN (R 4.3.0) #> R.utils 2.12.2 2022-11-11 [1] CRAN (R 4.3.0) #> R6 2.5.1 2021-08-19 [1] CRAN (R 4.3.0) #> Rcpp 1.0.11 2023-07-06 [1] CRAN (R 4.3.0) #> rematch2 2.1.2 2020-05-01 [1] CRAN (R 4.3.0) #> reprex 2.0.2 2022-08-17 [1] CRAN (R 4.3.0) #> rlang 1.1.1 2023-04-28 [1] CRAN (R 4.3.0) #> rmarkdown 2.24 2023-08-14 [1] CRAN (R 4.3.1) #> rstudioapi 0.15.0 2023-07-07 [1] CRAN (R 4.3.0) #> sandwich 3.0-2 2022-06-15 [1] CRAN (R 4.3.0) #> scales 1.2.1 2022-08-20 [1] CRAN (R 4.3.0) #> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.3.0) #> statsExpressions 1.5.1 2023-05-23 [1] local #> stringi 1.7.12 2023-01-11 [1] CRAN (R 4.3.0) #> stringr 1.5.0 2022-12-02 [1] CRAN (R 4.3.0) #> styler 1.10.2 2023-08-29 [1] CRAN (R 4.3.1) #> survival 3.5-7 2023-08-14 [1] CRAN (R 4.3.0) #> TH.data 1.1-2 2023-04-17 [1] CRAN (R 4.3.0) #> tibble 3.2.1 2023-03-20 [1] CRAN (R 4.3.0) #> tidyr 1.3.0 2023-01-24 [1] CRAN (R 4.3.0) #> tidyselect 1.2.0 2022-10-10 [1] CRAN (R 4.3.0) #> utf8 1.2.3 2023-01-31 [1] CRAN (R 4.3.0) #> vctrs 0.6.3 2023-06-14 [1] CRAN (R 4.3.0) #> withr 2.5.0 2022-03-03 [1] CRAN (R 4.3.0) #> xfun 0.40 2023-08-09 [1] CRAN (R 4.3.0) #> xtable 1.8-4 2019-04-21 [1] CRAN (R 4.3.0) #> yaml 2.3.7 2023-01-23 [1] CRAN (R 4.3.0) #> zeallot 0.1.0 2018-01-28 [1] CRAN (R 4.3.0) #> zoo 1.8-12 2023-04-13 [1] CRAN (R 4.3.0) #> #> [1] /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library #> #> ────────────────────────────────────────────────────────────────────────────── ```

Can you check the session information here and see if you are missing any of the dependencies?

lxsteiner commented 1 year ago

Thank you for the reply. After library(ggstatsplot) not all packages get loaded for some reason:

sessioninfo::session_info()
─ Session info ────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.2.2 (2022-10-31 ucrt)
 os       Windows 10 x64 (build 19045)
 system   x86_64, mingw32
 ui       RStudio
 language en
 collate  German_Germany.utf8
 ctype    German_Germany.utf8
 tz       Europe/Prague
 date     2023-09-07
 rstudio  2022.12.0+353 Elsbeth Geranium (desktop)
 pandoc   NA

─ Packages ────────────────────────────────────────────────────────────────────────────────────────────────────
 ! package          * version date (UTC) lib source
 P bayestestR         0.13.1  2023-04-07 [?] RSPM (R 4.2.0)
 P cli                3.6.1   2023-03-23 [?] RSPM (R 4.2.0)
 P colorspace         2.1-0   2023-01-23 [?] RSPM (R 4.2.0)
 P correlation        0.8.4   2023-04-06 [?] RSPM (R 4.2.0)
 P datawizard         0.8.0   2023-06-16 [?] RSPM (R 4.2.0)
 P dplyr              1.1.3   2023-09-03 [?] RSPM (R 4.2.0)
 P fansi              1.0.4   2023-01-22 [?] RSPM (R 4.2.0)
 P generics           0.1.3   2022-07-05 [?] RSPM (R 4.2.0)
 P ggplot2            3.4.3   2023-08-14 [?] RSPM (R 4.2.0)
 P ggstatsplot      * 0.12.0  2023-08-07 [?] RSPM (R 4.2.0)
 P glue               1.6.2   2022-02-24 [?] RSPM (R 4.2.0)
 P gtable             0.3.4   2023-08-21 [?] RSPM (R 4.2.0)
 P insight            0.19.3  2023-06-29 [?] RSPM (R 4.2.0)
 P lifecycle          1.0.3   2022-10-07 [?] RSPM (R 4.2.0)
 P magrittr           2.0.3   2022-03-30 [?] RSPM (R 4.2.0)
 P munsell            0.5.0   2018-06-12 [?] RSPM (R 4.2.0)
 P paletteer          1.5.0   2022-10-19 [?] RSPM (R 4.2.0)
 P parameters         0.21.1  2023-05-26 [?] RSPM (R 4.2.0)
 P patchwork          1.1.3   2023-08-14 [?] RSPM (R 4.2.0)
 P pillar             1.9.0   2023-03-22 [?] RSPM (R 4.2.0)
 P pkgconfig          2.0.3   2019-09-22 [?] RSPM (R 4.2.0)
 P purrr              1.0.2   2023-08-10 [?] RSPM (R 4.2.0)
 P R6                 2.5.1   2021-08-19 [?] RSPM (R 4.2.0)
 P rematch2           2.1.2   2020-05-01 [?] RSPM (R 4.2.0)
   renv               1.0.2   2023-08-15 [1] CRAN (R 4.2.3)
 P rlang              1.1.1   2023-04-28 [?] RSPM (R 4.2.0)
 P rstudioapi         0.15.0  2023-07-07 [?] RSPM (R 4.2.0)
 P scales             1.2.1   2022-08-20 [?] RSPM (R 4.2.0)
 P sessioninfo      * 1.2.2   2021-12-06 [?] RSPM (R 4.2.0)
 P statsExpressions   1.5.1   2023-05-23 [?] RSPM (R 4.2.0)
 P tibble             3.2.1   2023-03-20 [?] RSPM (R 4.2.0)
 P tidyselect         1.2.0   2022-10-10 [?] RSPM (R 4.2.0)
 P utf8               1.2.3   2023-01-31 [?] RSPM (R 4.2.0)
 P vctrs              0.6.3   2023-06-14 [?] RSPM (R 4.2.0)
 P zeallot            0.1.0   2018-01-28 [?] RSPM (R 4.2.0)

 [1] C:/Users//Documents/misc/ggstatsplot_plotting/renv/library/R-4.2/x86_64-w64-mingw32
 [2] C:/Users//AppData/Local/R/cache/R/renv/sandbox/R-4.2/x86_64-w64-mingw32/611f223d

 P ── Loaded and on-disk path mismatch.

But when I inspect what was installed:

> installed.packages()
abind
afex
backports
base64enc
BayesFactor
bayestestR
brio
broom
bslib
BWStest
cachem
callr
car
carData
cli
clipr
coda
colorspace
contfrac
correlation
corrplot
cowplot
cpp11
crayon
datawizard
desc
deSolve
diffobj
digest
dplyr
effectsize
ellipsis
elliptic
evaluate
fansi
farver
fastmap
fontawesome
fs
generics
ggcorrplot
ggplot2
ggpubr
ggrepel
ggsci
ggside
ggsignif
ggstatsplot
glue
gmp
gridExtra
gtable
highr
htmltools
hypergeo
insight
isoband
jquerylib
jsonlite
knitr
kSamples
labeling
lifecycle
lme4
lmerTest
magrittr
MatrixModels
mc2d
memoise
mime
minqa
multcompView
munsell
mvtnorm
nloptr
numDeriv
paletteer
parameters
patchwork
pbapply
pbkrtest
performance
pillar
pkgconfig
pkgload
plyr
PMCMRplus
polynom
praise
prismatic
processx
ps
purrr
quantreg
R6
rappdirs
RColorBrewer
Rcpp
RcppEigen
rematch2
renv
reprex
reshape
reshape2
rlang
rmarkdown
Rmpfr
rprojroot
rstatix
rstudioapi
sass
scales
sessioninfo
SparseM
statsExpressions
stringi
stringr
SuppDists
testthat
tibble
tidyr
tidyselect
tinytex
utf8
vctrs
viridisLite
waldo
withr
WRS2
xfun
yaml
zeallot   

They seem to be installed. Not sure what's going on. Any idea what I might be doing wrong? Thank you.

IndrajeetPatil commented 1 year ago

@lxsteiner Are you still seeing the same issue? Even after updating to the latest version of ggstatsplot (0.12.1)?

lxsteiner commented 6 months ago

@IndrajeetPatil I couldn't get it to work, even after installing the newest version of all required packages. In the meantime, I did a clean new install of the most recent R version and installed everything again. The issue did not happen afterwards. Maybe it was some package mismatch with that particular version of R (4.2.2)... πŸ€·β€β™‚οΈ who knows. Thanks nevertheless.