IndrajeetPatil / ggstatsplot

Enhancing {ggplot2} plots with statistical analysis 📊📣
https://indrajeetpatil.github.io/ggstatsplot/
GNU General Public License v3.0
2.04k stars 190 forks source link

not all pairwise comparisons are sometimes displayed in `ggbetweenstats` #376

Closed IndrajeetPatil closed 3 years ago

IndrajeetPatil commented 4 years ago

The comparison between 80 and 90 is missing.

You can see it in the pairwiseComparisons output, and yet it is not present in the geom_ggsignif data.

So is this ggstatsplot or ggsignif issue?

# setup
set.seed(123)
library(tidyverse)
options(tibble.print_max = Inf)

# dataframe
df <- structure(list(
  x = c(
    30, 40, 50, 60, 70, 80, 90, 30, 40, 50,
    60, 70, 80, 90, 30, 40, 50, 60, 70, 80, 90, 30, 40, 50, 60, 70,
    80, 90, 30, 40, 50, 60, 70, 80, 90
  ),
  Participant = c(
    "FH2", "FH2",
    "FH2", "FH2", "FH2", "FH2", "FH2", "ZW", "ZW", "ZW", "ZW", "ZW",
    "ZW", "ZW", "KS", "KS", "KS", "KS", "KS", "KS", "KS", "CL", "CL",
    "CL", "CL", "CL", "CL", "CL", "AG", "AG", "AG", "AG", "AG", "AG",
    "AG"
  ),
  Method = c(
    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
  ),
  y = c(
    2571.25, 2688.003333, 2779.363333, 2832.046667,
    3050.72, 3255.553333, 3327.173667, 1766.296667, 2107.890333,
    2391.7, 2569.24, 2680.22, 2807.59, 2807.953333, 2078.734,
    2414.366667, 2583.27, 2923.253333, 3085.96, 3094.003333,
    3121.49, 2824.990667, 2716.429667, 2844.323333, 3124.713333,
    3252.863333, 3424.24, 3674.463333, 2401.996667, 2719.046667,
    2712.99, 2951.965667, 3046.526667, 3100.902667, 3195.331333
  )
),
class = c("spec_tbl_df", "tbl_df", "tbl", "data.frame"),
row.names = c(NA, -35L),
spec = structure(list(
  cols = list(
    x = structure(list(), class = c("collector_double", "collector")),
    Participant = structure(list(), class = c(
      "collector_character",
      "collector"
    )),
    Method = structure(list(), class = c(
      "collector_double",
      "collector"
    )),
    y = structure(list(), class = c(
      "collector_double",
      "collector"
    ))
  ),
  default = structure(list(), class = c(
    "collector_guess",
    "collector"
  )), skip = 1
),
class = "col_spec"
)
)

# plot
p <-
  ggstatsplot::ggwithinstats(
    data = df,
    x = x,
    y = y,
    pairwise.display = "everything",
    pairwise.annotation = "p.value",
    pairwise.comparisons = TRUE,
    messages = TRUE
  )

#> Warning:  No. of factor levels is greater than no. of observations per cell.
#>  No sphericity correction applied. Interpret the results with caution.

#> Warning in log(det(U)): NaNs produced
#> Note: 95% CI for effect size estimate was computed with 100 bootstrap samples.

#> Warning: `fun.y` is deprecated. Use `fun` instead.
#> # A tibble: 21 x 7
#>    group1 group2 mean.difference p.value significance test.details
#>    <chr>  <chr>            <dbl>   <dbl> <chr>        <chr>       
#>  1 30     40               200.  0.214   ns           Student's t…
#>  2 30     50               334.  0.214   ns           Student's t…
#>  3 30     60               552.  0.0848  ns           Student's t…
#>  4 30     70               695.  0.0459  *            Student's t…
#>  5 30     80               808.  0.0156  *            Student's t…
#>  6 30     90               897.  0.00266 **           Student's t…
#>  7 40     50               133.  0.214   ns           Student's t…
#>  8 40     60               351.  0.0730  ns           Student's t…
#>  9 40     70               494.  0.0225  *            Student's t…
#> 10 40     80               607.  0.0114  *            Student's t…
#> 11 40     90               696.  0.0153  *            Student's t…
#> 12 50     60               218.  0.0848  ns           Student's t…
#> 13 50     70               361.  0.0171  *            Student's t…
#> 14 50     80               474.  0.00313 **           Student's t…
#> 15 50     90               563.  0.0203  *            Student's t…
#> 16 60     70               143.  0.0378  *            Student's t…
#> 17 60     80               256.  0.0728  ns           Student's t…
#> 18 60     90               345.  0.0836  ns           Student's t…
#> 19 70     80               113.  0.214   ns           Student's t…
#> 20 70     90               202.  0.214   ns           Student's t…
#> 21 80     90                88.8 0.214   ns           Student's t…
#> # … with 1 more variable: p.value.adjustment <chr>
#> Note: Shapiro-Wilk Normality Test for y: p-value = 0.659
#> 
#> Note: Bartlett's test for homogeneity of variances for factor x: p-value = 0.670
#> 

plot(p)


pb <- ggplot2::ggplot_build(p)

tibble::as_tibble(pb$data[[7]])
#> # A tibble: 60 x 19
#>        x  xend     y  yend annotation group PANEL shape colour textsize angle
#>    <int> <int> <dbl> <dbl> <fct>      <fct> <fct> <dbl> <chr>     <dbl> <dbl>
#>  1     1     1 3747. 3766. list(~ita… 30-4… 1        19 black         3     0
#>  2     1     2 3766. 3766. list(~ita… 30-4… 1        19 black         3     0
#>  3     2     2 3766. 3747. list(~ita… 30-4… 1        19 black         3     0
#>  4     1     1 3847. 3867. list(~ita… 30-5… 1        19 black         3     0
#>  5     1     3 3867. 3867. list(~ita… 30-5… 1        19 black         3     0
#>  6     3     3 3867. 3847. list(~ita… 30-5… 1        19 black         3     0
#>  7     1     1 3948. 3967. list(~ita… 30-6… 1        19 black         3     0
#>  8     1     4 3967. 3967. list(~ita… 30-6… 1        19 black         3     0
#>  9     4     4 3967. 3948. list(~ita… 30-6… 1        19 black         3     0
#> 10     1     1 4048. 4067. list(~ita… 30-7… 1        19 black         3     0
#> 11     1     5 4067. 4067. list(~ita… 30-7… 1        19 black         3     0
#> 12     5     5 4067. 4048. list(~ita… 30-7… 1        19 black         3     0
#> 13     1     1 4148. 4167. list(~ita… 30-8… 1        19 black         3     0
#> 14     1     6 4167. 4167. list(~ita… 30-8… 1        19 black         3     0
#> 15     6     6 4167. 4148. list(~ita… 30-8… 1        19 black         3     0
#> 16     1     1 4248. 4267. list(~ita… 30-9… 1        19 black         3     0
#> 17     1     7 4267. 4267. list(~ita… 30-9… 1        19 black         3     0
#> 18     7     7 4267. 4248. list(~ita… 30-9… 1        19 black         3     0
#> 19     2     2 4348. 4367. list(~ita… 40-5… 1        19 black         3     0
#> 20     2     3 4367. 4367. list(~ita… 40-5… 1        19 black         3     0
#> 21     3     3 4367. 4348. list(~ita… 40-5… 1        19 black         3     0
#> 22     2     2 4448. 4468. list(~ita… 40-6… 1        19 black         3     0
#> 23     2     4 4468. 4468. list(~ita… 40-6… 1        19 black         3     0
#> 24     4     4 4468. 4448. list(~ita… 40-6… 1        19 black         3     0
#> 25     2     2 4549. 4568. list(~ita… 40-7… 1        19 black         3     0
#> 26     2     5 4568. 4568. list(~ita… 40-7… 1        19 black         3     0
#> 27     5     5 4568. 4549. list(~ita… 40-7… 1        19 black         3     0
#> 28     2     2 4649. 4668. list(~ita… 40-8… 1        19 black         3     0
#> 29     2     6 4668. 4668. list(~ita… 40-8… 1        19 black         3     0
#> 30     6     6 4668. 4649. list(~ita… 40-8… 1        19 black         3     0
#> 31     2     2 4749. 4768. list(~ita… 40-9… 1        19 black         3     0
#> 32     2     7 4768. 4768. list(~ita… 40-9… 1        19 black         3     0
#> 33     7     7 4768. 4749. list(~ita… 40-9… 1        19 black         3     0
#> 34     3     3 4849. 4868. list(~ita… 50-6… 1        19 black         3     0
#> 35     3     4 4868. 4868. list(~ita… 50-6… 1        19 black         3     0
#> 36     4     4 4868. 4849. list(~ita… 50-6… 1        19 black         3     0
#> 37     3     3 4949. 4968. list(~ita… 50-7… 1        19 black         3     0
#> 38     3     5 4968. 4968. list(~ita… 50-7… 1        19 black         3     0
#> 39     5     5 4968. 4949. list(~ita… 50-7… 1        19 black         3     0
#> 40     3     3 5050. 5069. list(~ita… 50-8… 1        19 black         3     0
#> 41     3     6 5069. 5069. list(~ita… 50-8… 1        19 black         3     0
#> 42     6     6 5069. 5050. list(~ita… 50-8… 1        19 black         3     0
#> 43     3     3 5150. 5169. list(~ita… 50-9… 1        19 black         3     0
#> 44     3     7 5169. 5169. list(~ita… 50-9… 1        19 black         3     0
#> 45     7     7 5169. 5150. list(~ita… 50-9… 1        19 black         3     0
#> 46     4     4 5250. 5269. list(~ita… 60-7… 1        19 black         3     0
#> 47     4     5 5269. 5269. list(~ita… 60-7… 1        19 black         3     0
#> 48     5     5 5269. 5250. list(~ita… 60-7… 1        19 black         3     0
#> 49     4     4 5350. 5369. list(~ita… 60-8… 1        19 black         3     0
#> 50     4     6 5369. 5369. list(~ita… 60-8… 1        19 black         3     0
#> 51     6     6 5369. 5350. list(~ita… 60-8… 1        19 black         3     0
#> 52     4     4 5450. 5469. list(~ita… 60-9… 1        19 black         3     0
#> 53     4     7 5469. 5469. list(~ita… 60-9… 1        19 black         3     0
#> 54     7     7 5469. 5450. list(~ita… 60-9… 1        19 black         3     0
#> 55     5     5 5550. 5570. list(~ita… 70-8… 1        19 black         3     0
#> 56     5     6 5570. 5570. list(~ita… 70-8… 1        19 black         3     0
#> 57     6     6 5570. 5550. list(~ita… 70-8… 1        19 black         3     0
#> 58     5     5 5651. 5670. list(~ita… 70-9… 1        19 black         3     0
#> 59     5     7 5670. 5670. list(~ita… 70-9… 1        19 black         3     0
#> 60     7     7 5670. 5651. list(~ita… 70-9… 1        19 black         3     0
#> # … with 8 more variables: hjust <dbl>, vjust <dbl>, alpha <lgl>, family <chr>,
#> #   fontface <dbl>, lineheight <dbl>, linetype <dbl>, size <dbl>

Created on 2020-02-19 by the reprex package (v0.3.0)

Session info ``` r devtools::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 3.6.2 (2019-12-12) #> os macOS Mojave 10.14.6 #> system x86_64, darwin15.6.0 #> ui X11 #> language (EN) #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz Europe/Berlin #> date 2020-02-19 #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date lib #> abind 1.4-5 2016-07-21 [1] #> assertthat 0.2.1 2019-03-21 [1] #> backports 1.1.5 2019-10-02 [1] #> base64enc 0.1-3 2015-07-28 [1] #> BayesFactor 0.9.12-4.2 2018-05-19 [1] #> bayestestR 0.5.2 2020-02-13 [1] #> bbmle 1.0.23.1 2020-02-03 [1] #> bdsmatrix 1.3-4 2020-01-13 [1] #> boot 1.3-24 2019-12-20 [1] #> bridgesampling 0.8-1 2020-01-16 [1] #> Brobdingnag 1.2-6 2018-08-13 [1] #> broom 0.5.4 2020-01-27 [1] #> broom.mixed 0.2.4 2019-02-21 [1] #> broomExtra 1.0.1 2020-01-07 [1] #> callr 3.4.2 2020-02-12 [1] #> car 3.0-6 2019-12-23 [1] #> carData 3.0-3 2019-11-16 [1] #> cellranger 1.1.0 2016-07-27 [1] #> cli 2.0.1 2020-01-08 [1] #> cluster 2.1.0 2019-06-19 [2] #> coda 0.19-3 2019-07-05 [1] #> codetools 0.2-16 2018-12-24 [2] #> coin 1.3-1 2019-08-28 [1] #> colorspace 1.4-1 2019-03-18 [1] #> cowplot 1.0.0 2019-07-11 [1] #> crayon 1.3.4 2017-09-16 [1] #> curl 4.3 2019-12-02 [1] #> data.table 1.12.8 2019-12-09 [1] #> DBI 1.1.0 2019-12-15 [1] #> dbplyr 1.4.2 2019-06-17 [1] #> desc 1.2.0 2018-05-01 [1] #> DescTools 0.99.32 2020-01-17 [1] #> devtools 2.2.2 2020-02-17 [1] #> dichromat 2.0-0 2013-01-24 [1] #> digest 0.6.24 2020-02-12 [1] #> dplyr * 0.8.4 2020-01-31 [1] #> effectsize 0.1.2 2020-02-13 [1] #> ellipsis 0.3.0 2019-09-20 [1] #> emmeans 1.4.4 2020-01-28 [1] #> EMT 1.1 2013-01-29 [1] #> estimability 1.3 2018-02-11 [1] #> evaluate 0.14 2019-05-28 [1] #> expm 0.999-4 2019-03-21 [1] #> ez 4.4-0 2016-11-02 [1] #> fansi 0.4.1 2020-01-08 [1] #> farver 2.0.3 2020-01-16 [1] #> fastGHQuad 1.0 2018-09-30 [1] #> fastmap 1.0.1 2019-10-08 [1] #> forcats * 0.4.0 2019-02-17 [1] #> foreign 0.8-72 2019-08-02 [2] #> fs 1.3.1 2019-05-06 [1] #> generics 0.0.2 2018-11-29 [1] #> ggcorrplot 0.1.3 2019-05-19 [1] #> ggExtra 0.9 2019-08-27 [1] #> ggplot2 * 3.3.0.9000 2020-02-18 [1] #> ggrepel 0.8.1 2019-05-07 [1] #> ggsignif 0.6.0 2019-08-08 [1] #> ggstatsplot 0.3.0.9000 2020-02-18 [1] #> glue 1.3.1 2019-03-12 [1] #> gridExtra 2.3 2017-09-09 [1] #> groupedstats 0.1.1 2020-01-14 [1] #> gtable 0.3.0 2019-03-25 [1] #> gtools 3.8.1 2018-06-26 [1] #> haven 2.2.0 2019-11-08 [1] #> highr 0.8 2019-03-20 [1] #> hms 0.5.3 2020-01-08 [1] #> htmltools 0.4.0 2019-10-04 [1] #> httpuv 1.5.2 2019-09-11 [1] #> httr 1.4.1 2019-08-05 [1] #> inline 0.3.15 2018-05-18 [1] #> insight 0.8.1.1 2020-02-13 [1] #> ipmisc 1.1.0 2020-02-09 [1] #> jcolors 0.0.4 2019-05-22 [1] #> jmv 1.2.5 2020-02-17 [1] #> jmvcore 1.2.5 2020-02-05 [1] #> jsonlite 1.6.1 2020-02-02 [1] #> knitr 1.28 2020-02-06 [1] #> labeling 0.3 2014-08-23 [1] #> LaplacesDemon 16.1.4 2020-02-06 [1] #> later 1.0.0 2019-10-04 [1] #> lattice 0.20-38 2018-11-04 [2] #> libcoin 1.0-5 2019-08-27 [1] #> lifecycle 0.1.0 2019-08-01 [1] #> lme4 1.1-21 2019-03-05 [1] #> lmtest 0.9-37 2019-04-30 [1] #> logspline 2.1.15 2019-11-08 [1] #> loo 2.2.0 2019-12-19 [1] #> lubridate 1.7.4 2018-04-11 [1] #> magrittr 1.5 2014-11-22 [1] #> mapproj 1.2.7 2020-02-03 [1] #> maps 3.3.0 2018-04-03 [1] #> MASS 7.3-51.4 2019-03-31 [2] #> Matrix 1.2-18 2019-11-27 [2] #> MatrixModels 0.4-1 2015-08-22 [1] #> matrixStats 0.55.0 2019-09-07 [1] #> mc2d 0.1-18 2017-03-06 [1] #> memoise 1.1.0 2017-04-21 [1] #> metaBMA 0.6.2 2019-09-16 [1] #> metafor 2.1-0 2019-05-14 [1] #> metaplus 0.7-11 2018-04-01 [1] #> mgcv 1.8-31 2019-11-09 [2] #> mime 0.9 2020-02-04 [1] #> miniUI 0.1.1.1 2018-05-18 [1] #> minqa 1.2.4 2014-10-09 [1] #> mnormt 1.5-6 2020-02-03 [1] #> modelr 0.1.5 2019-08-08 [1] #> modeltools 0.2-22 2018-07-16 [1] #> multcomp 1.4-12 2020-01-10 [1] #> multcompView 0.1-8 2019-12-19 [1] #> munsell 0.5.0 2018-06-12 [1] #> mvtnorm 1.0-12 2020-01-09 [1] #> nlme 3.1-142 2019-11-07 [2] #> nloptr 1.2.1 2018-10-03 [1] #> nortest 1.0-4 2015-07-30 [1] #> numDeriv 2016.8-1.1 2019-06-06 [1] #> oompaBase 3.2.9 2019-08-24 [1] #> openxlsx 4.1.4 2019-12-06 [1] #> pairwiseComparisons 0.2.5 2020-02-11 [1] #> paletteer 1.0.0 2019-12-18 [1] #> palr 0.2.0 2020-01-30 [1] #> pals 1.6 2019-12-04 [1] #> parameters 0.5.0.1 2020-02-13 [1] #> pbapply 1.4-2 2019-08-31 [1] #> performance 0.4.4.1 2020-02-13 [1] #> pillar 1.4.3 2019-12-20 [1] #> pkgbuild 1.0.6 2019-10-09 [1] #> pkgconfig 2.0.3 2019-09-22 [1] #> pkgload 1.0.2 2018-10-29 [1] #> plyr 1.8.5 2019-12-10 [1] #> prettyunits 1.1.1 2020-01-24 [1] #> prismatic 0.2.0 2019-12-01 [1] #> processx 3.4.2 2020-02-09 [1] #> promises 1.1.0 2019-10-04 [1] #> ps 1.3.2 2020-02-13 [1] #> psych 1.9.12.31 2020-01-08 [1] #> purrr * 0.3.3 2019-10-18 [1] #> R6 2.4.1 2019-11-12 [1] #> rcompanion 2.3.25 2020-02-09 [1] #> Rcpp 1.0.3 2019-11-08 [1] #> readr * 1.3.1 2018-12-21 [1] #> readxl 1.3.1 2019-03-13 [1] #> rematch2 2.1.0 2019-07-11 [1] #> remotes 2.1.1 2020-02-15 [1] #> repr 1.1.0 2020-01-28 [1] #> reprex 0.3.0 2019-05-16 [1] #> reshape 0.8.8 2018-10-23 [1] #> reshape2 1.4.3 2017-12-11 [1] #> rio 0.5.16 2018-11-26 [1] #> rjson 0.2.20 2018-06-08 [1] #> rlang 0.4.4 2020-01-28 [1] #> rmarkdown 2.1 2020-01-20 [1] #> rprojroot 1.3-2 2018-01-03 [1] #> rstan 2.19.3 2020-02-11 [1] #> rstantools 2.0.0 2019-09-15 [1] #> rstudioapi 0.11 2020-02-07 [1] #> rvest 0.3.5 2019-11-08 [1] #> sandwich 2.5-1 2019-04-06 [1] #> scales 1.1.0 2019-11-18 [1] #> scico 1.1.0 2018-11-20 [1] #> sessioninfo 1.1.1 2018-11-05 [1] #> shiny 1.4.0 2019-10-10 [1] #> sjlabelled 1.1.3 2020-01-28 [1] #> sjmisc 2.8.3 2020-01-10 [1] #> sjstats 0.17.9 2020-02-06 [1] #> skimr 2.1 2020-02-01 [1] #> StanHeaders 2.21.0-1 2020-01-19 [1] #> statsExpressions 0.3.1 2020-02-14 [1] #> stringi 1.4.6 2020-02-17 [1] #> stringr * 1.4.0 2019-02-10 [1] #> survival 3.1-8 2019-12-03 [2] #> testthat 2.3.1 2019-12-01 [1] #> TH.data 1.0-10 2019-01-21 [1] #> tibble * 2.1.3 2019-06-06 [1] #> tidyr * 1.0.2 2020-01-24 [1] #> tidyselect 1.0.0 2020-01-27 [1] #> tidyverse * 1.3.0 2019-11-21 [1] #> TMB 1.7.16 2020-01-15 [1] #> usethis 1.5.1.9000 2020-02-18 [1] #> utf8 1.1.4 2018-05-24 [1] #> vctrs 0.2.2 2020-01-24 [1] #> withr 2.1.2 2018-03-15 [1] #> WRS2 1.0-0 2019-06-06 [1] #> xfun 0.12 2020-01-13 [1] #> xml2 1.2.2 2019-08-09 [1] #> xtable 1.8-4 2019-04-21 [1] #> yaml 2.2.1 2020-02-01 [1] #> zeallot 0.1.0 2018-01-28 [1] #> zip 2.0.4 2019-09-01 [1] #> zoo 1.8-7 2020-01-10 [1] #> source #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> Github (easystats/bayestestR@4350b4f) #> CRAN (R 3.6.2) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> Github (easystats/effectsize@00c2136) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> Github (tidyverse/ggplot2@b434351) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> local #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.1) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> Github (easystats/INSIGHT@e4d69cf) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.2) #> CRAN (R 3.6.2) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.2) #> CRAN (R 3.6.2) #> CRAN (R 3.6.1) #> Github (easystats/parameters@d90a76a) #> CRAN (R 3.6.0) #> Github (easystats/performance@dc37a85) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.1) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.1) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.2) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.2) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> Github (r-lib/usethis@2a3d134) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.2) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> #> [1] /Users/patil/Library/R/3.6/library #> [2] /Library/Frameworks/R.framework/Versions/3.6/Resources/library ```
IndrajeetPatil commented 4 years ago

Doesn't seem to be a ggsignif issue. The 80-90 combo is present here.

Minimal reprex:

# setup
set.seed(123)
library(tidyverse)
options(tibble.print_max = Inf)

# dataframe
df <- structure(list(
  x = c(
    30, 40, 50, 60, 70, 80, 90, 30, 40, 50,
    60, 70, 80, 90, 30, 40, 50, 60, 70, 80, 90, 30, 40, 50, 60, 70,
    80, 90, 30, 40, 50, 60, 70, 80, 90
  ),
  Participant = c(
    "FH2", "FH2",
    "FH2", "FH2", "FH2", "FH2", "FH2", "ZW", "ZW", "ZW", "ZW", "ZW",
    "ZW", "ZW", "KS", "KS", "KS", "KS", "KS", "KS", "KS", "CL", "CL",
    "CL", "CL", "CL", "CL", "CL", "AG", "AG", "AG", "AG", "AG", "AG",
    "AG"
  ),
  Method = c(
    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
  ),
  y = c(
    2571.25, 2688.003333, 2779.363333, 2832.046667,
    3050.72, 3255.553333, 3327.173667, 1766.296667, 2107.890333,
    2391.7, 2569.24, 2680.22, 2807.59, 2807.953333, 2078.734,
    2414.366667, 2583.27, 2923.253333, 3085.96, 3094.003333,
    3121.49, 2824.990667, 2716.429667, 2844.323333, 3124.713333,
    3252.863333, 3424.24, 3674.463333, 2401.996667, 2719.046667,
    2712.99, 2951.965667, 3046.526667, 3100.902667, 3195.331333
  )
),
class = c("spec_tbl_df", "tbl_df", "tbl", "data.frame"),
row.names = c(NA, -35L),
spec = structure(list(
  cols = list(
    x = structure(list(), class = c("collector_double", "collector")),
    Participant = structure(list(), class = c(
      "collector_character",
      "collector"
    )),
    Method = structure(list(), class = c(
      "collector_double",
      "collector"
    )),
    y = structure(list(), class = c(
      "collector_double",
      "collector"
    ))
  ),
  default = structure(list(), class = c(
    "collector_guess",
    "collector"
  )), skip = 1
),
class = "col_spec"
)
)

library(ggplot2)
library(ggsignif)

df$x <- as.character(df$x)
combos <- utils::combn(unique(df$x), 2, simplify = FALSE)

ggplot(df, aes(x, y)) +
  geom_boxplot() +
  geom_signif(comparisons = combos, step_increase = 0.2)

Created on 2020-02-19 by the reprex package (v0.3.0)

IndrajeetPatil commented 3 years ago

Clearly this has something to do with the message:

Warning in log(det(U)): NaNs produced

# setup
set.seed(123)
library(tidyverse)
options(tibble.print_max = Inf)

# dataframe
df <- structure(list(
  x = c(
    30, 40, 50, 60, 70, 80, 90, 30, 40, 50,
    60, 70, 80, 90, 30, 40, 50, 60, 70, 80, 90, 30, 40, 50, 60, 70,
    80, 90, 30, 40, 50, 60, 70, 80, 90
  ),
  Participant = c(
    "FH2", "FH2",
    "FH2", "FH2", "FH2", "FH2", "FH2", "ZW", "ZW", "ZW", "ZW", "ZW",
    "ZW", "ZW", "KS", "KS", "KS", "KS", "KS", "KS", "KS", "CL", "CL",
    "CL", "CL", "CL", "CL", "CL", "AG", "AG", "AG", "AG", "AG", "AG",
    "AG"
  ),
  Method = c(
    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
  ),
  y = c(
    2571.25, 2688.003333, 2779.363333, 2832.046667,
    3050.72, 3255.553333, 3327.173667, 1766.296667, 2107.890333,
    2391.7, 2569.24, 2680.22, 2807.59, 2807.953333, 2078.734,
    2414.366667, 2583.27, 2923.253333, 3085.96, 3094.003333,
    3121.49, 2824.990667, 2716.429667, 2844.323333, 3124.713333,
    3252.863333, 3424.24, 3674.463333, 2401.996667, 2719.046667,
    2712.99, 2951.965667, 3046.526667, 3100.902667, 3195.331333
  )
),
class = c("spec_tbl_df", "tbl_df", "tbl", "data.frame"),
row.names = c(NA, -35L),
spec = structure(list(
  cols = list(
    x = structure(list(), class = c("collector_double", "collector")),
    Participant = structure(list(), class = c(
      "collector_character",
      "collector"
    )),
    Method = structure(list(), class = c(
      "collector_double",
      "collector"
    )),
    y = structure(list(), class = c(
      "collector_double",
      "collector"
    ))
  ),
  default = structure(list(), class = c(
    "collector_guess",
    "collector"
  )), skip = 1
),
class = "col_spec"
)
)

# 80-90 comparison present
ggstatsplot::ggwithinstats(
  data = dplyr::filter(df, x > 40),
  x = x,
  y = y,
  pairwise.display = "everything",
)
#> Registered S3 method overwritten by 'broom.mixed':
#>   method      from 
#>   tidy.gamlss broom
#> Registered S3 methods overwritten by 'lme4':
#>   method                          from
#>   cooks.distance.influence.merMod car 
#>   influence.merMod                car 
#>   dfbeta.influence.merMod         car 
#>   dfbetas.influence.merMod        car


# 80-90 comparison present
ggstatsplot::ggwithinstats(
  data = dplyr::filter(df, x > 30),
  x = x,
  y = y,
  pairwise.display = "everything",
)


# 80-90 comparison absent
ggstatsplot::ggwithinstats(
  data = dplyr::filter(df, x > 20),
  x = x,
  y = y,
  pairwise.display = "everything",
)
#> Warning in log(det(U)): NaNs produced

Created on 2020-11-18 by the reprex package (v0.3.0)

IndrajeetPatil commented 3 years ago

Hmm, don't see how can this affect pairwise comparison display

options(warn = 2)
ggstatsplot::ggwithinstats(
  data = dplyr::filter(df, x > 20),
  x = x,
  y = y,
  pairwise.display = "everything",
)

Error:

Error in log(det(U)) : (converted from warning) NaNs produced
Error in ezANOVA_main(data = data, dv = dv, wid = wid, within = within,  : 
  The car::Anova() function used to compute results and assumption tests seems to have failed. Most commonly this is because you have too few subjects relative to the number of cells in the within-Ss design. It is possible that trying the ANOVA again with "type=1" may yield results (but definitely no assumption tests).

Since the following still works:

ggstatsplot::ggwithinstats(
  data = dplyr::filter(df, x > 20),
  x = x,
  y = y,
  pairwise.display = "everything",
)
IndrajeetPatil commented 3 years ago

I am closing this for now. Will reopen it only if this behavior is observed with any other dataset. I am getting the feeling that this problem is specific to the current dataframe and not a general bug affecting all datasets.