From 62ecd0049c31d617895b38b236b6734762a7fba8 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Sun, 14 Jan 2024 15:47:08 +0100 Subject: [PATCH] CRAN RC 0.12.2 (#900) * change indentation for function signature * don't use devel roxygen2 * update tests for change in starwars data in dplyr * update citation * Update pkgdown.yaml * needed for tests * clean newer lints * don't use starwars dataset which receives updates * better naming instead of reusing base object names * remove unnecessary keyword args in testthat calls * don't nest pipe * Update R-CMD-check.yaml * try easystats trick * Revert "try easystats trick" This reverts commit 94e27ed9412018871b3bd0374459436648bfe970. * Update R-CMD-check.yaml * Update test-ggdotplotstats.R * update lintr * follow kebab-case for file naming * Apply automatic changes * use latest lme4 for Matrix updates * correct way to remove violin plot * bump Pandoc * regenerate snapshots * Apply automatic changes * Revert "regenerate snapshots" This reverts commit ea76caef1b5d4db03c2d55fe5bc9555310acdcf3. * Apply automatic changes * generate snaps for new file names * run workflows on r-release; bump Pandoc * update metadata * simplify extractors * bump roxygen2 version * use latest statsExpressions * bump patchwork * run on r-devel * run two more workflows on r-devel * bump version * Update R-CMD-check.yaml --------- Co-authored-by: IndrajeetPatil --- .Rbuildignore | 1 + .github/workflows/R-CMD-check-devel.yaml | 2 +- .github/workflows/R-CMD-check-hard.yaml | 2 +- .github/workflows/R-CMD-check-strict.yaml | 2 +- .github/workflows/R-CMD-check.yaml | 8 +- .github/workflows/check-link-rot.yaml | 2 +- .../workflows/check-random-test-order.yaml | 4 +- .github/workflows/check-readme.yaml | 2 +- .github/workflows/check-spelling.yaml | 2 +- .../workflows/check-vignette-warnings.yaml | 2 +- .github/workflows/pkgdown-no-suggests.yaml | 2 +- .github/workflows/pkgdown.yaml | 4 +- .github/workflows/pre-commit.yaml | 2 +- .github/workflows/styler.yaml | 2 +- .github/workflows/test-coverage.yaml | 3 +- .lintr | 6 +- .ls-lint.yml | 2 + CITATION.cff | 127 +++++++----- DESCRIPTION | 29 ++- NEWS.md | 6 +- R/{combine_plots.R => combine-plots.R} | 11 +- R/{extract_stats.R => extract-stats.R} | 4 +- R/ggbarstats.R | 76 +++---- ...ats_helpers.R => ggbetweenstats-helpers.R} | 79 ++++---- R/ggbetweenstats.R | 123 +++++------ R/ggcoefstats.R | 77 +++---- R/ggcorrmat.R | 62 +++--- R/ggdotplotstats.R | 72 +++---- ...stats_helpers.R => gghistostats-helpers.R} | 0 R/gghistostats.R | 83 ++++---- ...pers.R => ggpiestats-ggbarstats-helpers.R} | 21 +- R/ggpiestats.R | 72 +++---- R/ggscatterstats.R | 68 ++++--- R/ggwithinstats.R | 105 +++++----- R/globals.R | 6 +- R/reexports.R | 2 +- ...heme_ggstatsplot.R => theme-ggstatsplot.R} | 0 R/utils.R | 6 +- codemeta.json | 39 ++-- data-raw/{Titanic_full.R => Titanic-full.R} | 6 +- data-raw/{bugs_long.R => bugs-long.R} | 0 data-raw/{bugs_wide.R => bugs-wide.R} | 0 data-raw/{iris_long.R => iris-long.R} | 0 ...{movies_wide_long.R => movies-wide-long.R} | 14 +- man/combine_plots.Rd | 2 +- man/extract_stats.Rd | 2 +- man/ggbetweenstats.Rd | 6 +- man/ggstatsplot-package.Rd | 1 - man/ggwithinstats.Rd | 2 +- man/theme_ggstatsplot.Rd | 2 +- .../defaults-work-as-expected.svg | 0 .../{extract_stats.md => extract-stats.md} | 0 tests/testthat/_snaps/ggbarstats.md | 6 +- .../ggbetweenstats/specific-geoms-removed.svg | 4 +- tests/testthat/_snaps/ggcorrmat.md | 10 +- .../aesthetic-modifications-work.svg | 107 +++++----- .../_snaps/gghistostats/robust-with-na.svg | 191 +++++++++--------- .../adding-caption-works.svg | 0 .../between-bayes.svg | 0 .../between-non-parametric-all.svg | 0 ...en-non-parametric-only-non-significant.svg | 0 ...etween-non-parametric-only-significant.svg | 0 .../between-parametric-all.svg | 0 ...etween-parametric-only-non-significant.svg | 0 .../between-parametric-only-significant.svg | 0 .../between-robust-all.svg | 0 .../between-robust-only-non-significant.svg | 0 .../between-robust-only-significant.svg | 0 .../within-bayes.svg | 0 .../within-non-parametric-all.svg | 0 ...in-non-parametric-only-non-significant.svg | 0 ...within-non-parametric-only-significant.svg | 0 .../within-parametric-all.svg | 0 ...within-parametric-only-non-significant.svg | 0 .../within-parametric-only-significant.svg | 0 .../within-robust-all.svg | 0 .../within-robust-only-non-significant.svg | 0 .../within-robust-only-significant.svg | 0 ...t-combine_plots.R => test-combine-plots.R} | 4 +- ...t-extract_stats.R => test-extract-stats.R} | 4 +- tests/testthat/test-ggbarstats.R | 56 +++-- tests/testthat/test-ggbetweenstats.R | 14 +- tests/testthat/test-ggcoefstats.R | 22 +- tests/testthat/test-ggcorrmat.R | 27 +-- tests/testthat/test-ggdotplotstats.R | 39 ++-- tests/testthat/test-gghistostats.R | 36 ++-- tests/testthat/test-ggpiestats.R | 46 +++-- tests/testthat/test-ggscatterstats.R | 37 ++-- tests/testthat/test-ggwithinstats.R | 12 +- ...se_ggsignif.R => test-pairwise-ggsignif.R} | 117 ++++++++--- tests/testthat/test-utils.R | 12 +- 91 files changed, 1024 insertions(+), 871 deletions(-) create mode 100644 .ls-lint.yml rename R/{combine_plots.R => combine-plots.R} (90%) rename R/{extract_stats.R => extract-stats.R} (92%) rename R/{ggbetweenstats_helpers.R => ggbetweenstats-helpers.R} (78%) rename R/{gghistostats_helpers.R => gghistostats-helpers.R} (100%) rename R/{ggpiestats_ggbarstats_helpers.R => ggpiestats-ggbarstats-helpers.R} (83%) rename R/{theme_ggstatsplot.R => theme-ggstatsplot.R} (100%) rename data-raw/{Titanic_full.R => Titanic-full.R} (81%) rename data-raw/{bugs_long.R => bugs-long.R} (100%) rename data-raw/{bugs_wide.R => bugs-wide.R} (100%) rename data-raw/{iris_long.R => iris-long.R} (100%) rename data-raw/{movies_wide_long.R => movies-wide-long.R} (82%) rename tests/testthat/_snaps/{combine_plots => combine-plots}/defaults-work-as-expected.svg (100%) rename tests/testthat/_snaps/{extract_stats.md => extract-stats.md} (100%) rename tests/testthat/_snaps/{pairwise_ggsignif => pairwise-ggsignif}/adding-caption-works.svg (100%) rename tests/testthat/_snaps/{pairwise_ggsignif => pairwise-ggsignif}/between-bayes.svg (100%) rename tests/testthat/_snaps/{pairwise_ggsignif => pairwise-ggsignif}/between-non-parametric-all.svg (100%) rename tests/testthat/_snaps/{pairwise_ggsignif => pairwise-ggsignif}/between-non-parametric-only-non-significant.svg (100%) rename tests/testthat/_snaps/{pairwise_ggsignif => pairwise-ggsignif}/between-non-parametric-only-significant.svg (100%) rename tests/testthat/_snaps/{pairwise_ggsignif => pairwise-ggsignif}/between-parametric-all.svg (100%) rename tests/testthat/_snaps/{pairwise_ggsignif => pairwise-ggsignif}/between-parametric-only-non-significant.svg (100%) rename tests/testthat/_snaps/{pairwise_ggsignif => pairwise-ggsignif}/between-parametric-only-significant.svg (100%) rename tests/testthat/_snaps/{pairwise_ggsignif => pairwise-ggsignif}/between-robust-all.svg (100%) rename tests/testthat/_snaps/{pairwise_ggsignif => pairwise-ggsignif}/between-robust-only-non-significant.svg (100%) rename tests/testthat/_snaps/{pairwise_ggsignif => pairwise-ggsignif}/between-robust-only-significant.svg (100%) rename tests/testthat/_snaps/{pairwise_ggsignif => pairwise-ggsignif}/within-bayes.svg (100%) rename tests/testthat/_snaps/{pairwise_ggsignif => pairwise-ggsignif}/within-non-parametric-all.svg (100%) rename tests/testthat/_snaps/{pairwise_ggsignif => pairwise-ggsignif}/within-non-parametric-only-non-significant.svg (100%) rename tests/testthat/_snaps/{pairwise_ggsignif => pairwise-ggsignif}/within-non-parametric-only-significant.svg (100%) rename tests/testthat/_snaps/{pairwise_ggsignif => pairwise-ggsignif}/within-parametric-all.svg (100%) rename tests/testthat/_snaps/{pairwise_ggsignif => pairwise-ggsignif}/within-parametric-only-non-significant.svg (100%) rename tests/testthat/_snaps/{pairwise_ggsignif => pairwise-ggsignif}/within-parametric-only-significant.svg (100%) rename tests/testthat/_snaps/{pairwise_ggsignif => pairwise-ggsignif}/within-robust-all.svg (100%) rename tests/testthat/_snaps/{pairwise_ggsignif => pairwise-ggsignif}/within-robust-only-non-significant.svg (100%) rename tests/testthat/_snaps/{pairwise_ggsignif => pairwise-ggsignif}/within-robust-only-significant.svg (100%) rename tests/testthat/{test-combine_plots.R => test-combine-plots.R} (93%) rename tests/testthat/{test-extract_stats.R => test-extract-stats.R} (96%) rename tests/testthat/{test-pairwise_ggsignif.R => test-pairwise-ggsignif.R} (74%) diff --git a/.Rbuildignore b/.Rbuildignore index 28c9a0387..e1a72099b 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,3 +1,4 @@ +.ls-lint.yml ^.*\.Rproj$ ^.dev$ ^.gitlab-ci\.yml$ diff --git a/.github/workflows/R-CMD-check-devel.yaml b/.github/workflows/R-CMD-check-devel.yaml index d79561853..2383d9ba3 100644 --- a/.github/workflows/R-CMD-check-devel.yaml +++ b/.github/workflows/R-CMD-check-devel.yaml @@ -20,7 +20,7 @@ jobs: - uses: r-lib/actions/setup-pandoc@v2 with: - pandoc-version: "3.1.9" + pandoc-version: "3.1.11" - uses: r-lib/actions/setup-r@v2 with: diff --git a/.github/workflows/R-CMD-check-hard.yaml b/.github/workflows/R-CMD-check-hard.yaml index b5f58d190..da8dfc105 100644 --- a/.github/workflows/R-CMD-check-hard.yaml +++ b/.github/workflows/R-CMD-check-hard.yaml @@ -27,7 +27,7 @@ jobs: - uses: r-lib/actions/setup-pandoc@v2 with: - pandoc-version: "3.1.9" + pandoc-version: "3.1.11" - uses: r-lib/actions/setup-r@v2 with: diff --git a/.github/workflows/R-CMD-check-strict.yaml b/.github/workflows/R-CMD-check-strict.yaml index c19b3c2f0..6648e8f03 100644 --- a/.github/workflows/R-CMD-check-strict.yaml +++ b/.github/workflows/R-CMD-check-strict.yaml @@ -40,7 +40,7 @@ jobs: - uses: r-lib/actions/setup-pandoc@v2 with: - pandoc-version: "3.1.9" + pandoc-version: "3.1.11" - uses: r-lib/actions/setup-r@v2 with: diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index a5705fdcf..a86716bd6 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -27,11 +27,11 @@ jobs: #- { os: windows-latest, r: "devel" } - { os: windows-latest, r: "release" } - - { os: windows-latest, r: "oldrel-1" } + #- { os: windows-latest, r: "oldrel-1" } #- { os: ubuntu-latest, r: "devel" } - - { os: ubuntu-latest, r: "release" } - - { os: ubuntu-latest, r: "oldrel-1" } + #- { os: ubuntu-latest, r: "release" } + #- { os: ubuntu-latest, r: "oldrel-1" } env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} @@ -42,7 +42,7 @@ jobs: - uses: r-lib/actions/setup-pandoc@v2 with: - pandoc-version: "3.1.9" + pandoc-version: "3.1.11" - uses: r-lib/actions/setup-r@v2 with: diff --git a/.github/workflows/check-link-rot.yaml b/.github/workflows/check-link-rot.yaml index 1356aa094..ec87d8c8d 100644 --- a/.github/workflows/check-link-rot.yaml +++ b/.github/workflows/check-link-rot.yaml @@ -21,7 +21,7 @@ jobs: - uses: r-lib/actions/setup-pandoc@v2 with: - pandoc-version: "3.1.9" + pandoc-version: "3.1.11" - uses: r-lib/actions/setup-r@v2 with: diff --git a/.github/workflows/check-random-test-order.yaml b/.github/workflows/check-random-test-order.yaml index c8bccdc88..6d62ebab0 100644 --- a/.github/workflows/check-random-test-order.yaml +++ b/.github/workflows/check-random-test-order.yaml @@ -9,7 +9,7 @@ name: check-random-test-order jobs: check-random-test-order: - runs-on: ubuntu-latest + runs-on: macos-latest env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} @@ -18,7 +18,7 @@ jobs: - uses: r-lib/actions/setup-r@v2 with: - r-version: "release" + #r-version: "devel" use-public-rspm: true - uses: r-lib/actions/setup-r-dependencies@v2 diff --git a/.github/workflows/check-readme.yaml b/.github/workflows/check-readme.yaml index aea8eef77..7fd609ce2 100644 --- a/.github/workflows/check-readme.yaml +++ b/.github/workflows/check-readme.yaml @@ -30,7 +30,7 @@ jobs: - uses: r-lib/actions/setup-pandoc@v2 with: - pandoc-version: "3.1.9" + pandoc-version: "3.1.11" - uses: r-lib/actions/setup-r@v2 with: diff --git a/.github/workflows/check-spelling.yaml b/.github/workflows/check-spelling.yaml index 542c04e75..6e2bfc661 100644 --- a/.github/workflows/check-spelling.yaml +++ b/.github/workflows/check-spelling.yaml @@ -21,7 +21,7 @@ jobs: - uses: r-lib/actions/setup-pandoc@v2 with: - pandoc-version: "3.1.9" + pandoc-version: "3.1.11" - uses: r-lib/actions/setup-r@v2 with: diff --git a/.github/workflows/check-vignette-warnings.yaml b/.github/workflows/check-vignette-warnings.yaml index 29e5e6b8c..3739e41a9 100644 --- a/.github/workflows/check-vignette-warnings.yaml +++ b/.github/workflows/check-vignette-warnings.yaml @@ -18,7 +18,7 @@ jobs: - uses: r-lib/actions/setup-pandoc@v2 with: - pandoc-version: "3.1.9" + pandoc-version: "3.1.11" - uses: r-lib/actions/setup-r@v2 with: diff --git a/.github/workflows/pkgdown-no-suggests.yaml b/.github/workflows/pkgdown-no-suggests.yaml index d8cc87489..98ce10c6b 100644 --- a/.github/workflows/pkgdown-no-suggests.yaml +++ b/.github/workflows/pkgdown-no-suggests.yaml @@ -25,7 +25,7 @@ jobs: - uses: r-lib/actions/setup-pandoc@v2 with: - pandoc-version: "3.1.9" + pandoc-version: "3.1.11" - uses: r-lib/actions/setup-r@v2 with: diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index bed95d50c..fca14d168 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -24,7 +24,7 @@ jobs: - uses: r-lib/actions/setup-pandoc@v2 with: - pandoc-version: "3.1.9" + pandoc-version: "3.1.11" - uses: r-lib/actions/setup-r@v2 with: @@ -48,7 +48,7 @@ jobs: - name: Deploy to GitHub pages 🚀 if: github.event_name != 'pull_request' - uses: JamesIves/github-pages-deploy-action@v4.4.3 + uses: JamesIves/github-pages-deploy-action@v4.5.0 with: branch: gh-pages folder: docs diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml index 00c43673a..97b4e39e4 100644 --- a/.github/workflows/pre-commit.yaml +++ b/.github/workflows/pre-commit.yaml @@ -24,7 +24,7 @@ jobs: fetch-depth: 0 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.9" architecture: "x64" diff --git a/.github/workflows/styler.yaml b/.github/workflows/styler.yaml index 8ebd9946f..ede32000d 100644 --- a/.github/workflows/styler.yaml +++ b/.github/workflows/styler.yaml @@ -30,7 +30,7 @@ jobs: local::. r-lib/pkgapi r-lib/styler - r-lib/roxygen2 + any::roxygen2 anthonynorth/roxyglobals needs: | styler diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index ccd32f20f..e8e470266 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -10,7 +10,7 @@ name: test-coverage jobs: test-coverage: - runs-on: ubuntu-latest + runs-on: macos-latest env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} @@ -19,6 +19,7 @@ jobs: - uses: r-lib/actions/setup-r@v2 with: + #r-version: "devel" use-public-rspm: true - uses: r-lib/actions/setup-r-dependencies@v2 diff --git a/.lintr b/.lintr index 843f5e622..a7324e54e 100644 --- a/.lintr +++ b/.lintr @@ -1,9 +1,8 @@ -linters: linters_with_defaults( +linters: all_linters( absolute_path_linter = NULL, assignment_linter = NULL, commented_code_linter = NULL, cyclocomp_linter(25L), - extraction_operator_linter = NULL, if_not_else_linter(exceptions = character(0L)), implicit_integer_linter = NULL, library_call_linter = NULL, @@ -19,6 +18,5 @@ linters: linters_with_defaults( undesirable_function_linter = NULL, undesirable_operator_linter = NULL, unnecessary_concatenation_linter(allow_single_expression = FALSE), - unused_import_linter = NULL, - defaults = linters_with_tags(tags = NULL) + unused_import_linter = NULL ) diff --git a/.ls-lint.yml b/.ls-lint.yml new file mode 100644 index 000000000..0da089971 --- /dev/null +++ b/.ls-lint.yml @@ -0,0 +1,2 @@ +ls: + .R: kebab-case diff --git a/CITATION.cff b/CITATION.cff index ec2cc16fa..933d7de72 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -68,7 +68,7 @@ references: - name: R Core Team location: name: Vienna, Austria - year: '2023' + year: '2024' institution: name: R Foundation for Statistical Computing version: '>= 4.1.0' @@ -103,7 +103,7 @@ references: given-names: Rémi email: remi.theriault@mail.mcgill.ca orcid: https://orcid.org/0000-0003-4315-6788 - year: '2023' + year: '2024' version: '>= 0.8.4' - type: software title: datawizard @@ -136,8 +136,8 @@ references: given-names: Brenton M. email: brenton@wiernik.org orcid: https://orcid.org/0000-0001-9560-6336 - year: '2023' - version: '>= 0.9.0' + year: '2024' + version: '>= 0.9.1' - type: software title: dplyr abstract: 'dplyr: A Grammar of Data Manipulation' @@ -161,8 +161,8 @@ references: given-names: Davis email: davis@posit.co orcid: https://orcid.org/0000-0003-4777-038X - year: '2023' - version: '>= 1.1.3' + year: '2024' + version: '>= 1.1.4' - type: software title: ggcorrplot abstract: 'ggcorrplot: Visualization of a Correlation Matrix using ''ggplot2''' @@ -173,7 +173,7 @@ references: - family-names: Kassambara given-names: Alboukadel email: alboukadel.kassambara@gmail.com - year: '2023' + year: '2024' version: '>= 0.1.4.1' - type: software title: ggplot2 @@ -209,21 +209,21 @@ references: - family-names: Dunnington given-names: Dewey orcid: https://orcid.org/0000-0002-9415-4582 - year: '2023' + year: '2024' version: '>= 3.4.4' - type: software title: ggrepel abstract: 'ggrepel: Automatically Position Non-Overlapping Text Labels with ''ggplot2''' notes: Imports - url: https://github.com/slowkow/ggrepel + url: https://ggrepel.slowkow.com/ repository: https://CRAN.R-project.org/package=ggrepel authors: - family-names: Slowikowski given-names: Kamil email: kslowikowski@gmail.com orcid: https://orcid.org/0000-0002-2843-6370 - year: '2023' - version: '>= 0.9.4' + year: '2024' + version: '>= 0.9.5' - type: software title: ggside abstract: 'ggside: Side Grammar Graphics' @@ -235,8 +235,8 @@ references: given-names: Justin email: jtlandis314@gmail.com orcid: https://orcid.org/0000-0001-5501-4934 - year: '2023' - version: '>= 0.2.2' + year: '2024' + version: '>= 0.2.3' - type: software title: ggsignif abstract: 'ggsignif: Significance Brackets for ''ggplot2''' @@ -252,7 +252,7 @@ references: given-names: Indrajeet email: patilindrajeet.science@gmail.com orcid: https://orcid.org/0000-0003-1995-6531 - year: '2023' + year: '2024' version: '>= 0.6.4' - type: software title: glue @@ -266,9 +266,9 @@ references: orcid: https://orcid.org/0000-0002-2739-7082 - family-names: Bryan given-names: Jennifer - email: jenny@rstudio.com + email: jenny@posit.co orcid: https://orcid.org/0000-0002-6983-2759 - year: '2023' + year: '2024' - type: software title: insight abstract: 'insight: Easy Access to Model Information for Various Model Objects' @@ -308,8 +308,8 @@ references: given-names: Etienne email: etienne.bacher@protonmail.com orcid: https://orcid.org/0000-0002-9271-5075 - year: '2023' - version: '>= 0.19.6' + year: '2024' + version: '>= 0.19.7' - type: software title: paletteer abstract: 'paletteer: Comprehensive Collection of Color Palettes' @@ -319,7 +319,7 @@ references: authors: - family-names: file. given-names: See AUTHORS - year: '2023' + year: '2024' version: '>= 1.5.0' - type: software title: parameters @@ -351,8 +351,8 @@ references: given-names: Brenton M. email: brenton@wiernik.org orcid: https://orcid.org/0000-0001-9560-6336 - year: '2023' - version: '>= 0.21.2' + year: '2024' + version: '>= 0.21.3' - type: software title: patchwork abstract: 'patchwork: The Composer of Plots' @@ -364,14 +364,14 @@ references: given-names: Thomas Lin email: thomasp85@gmail.com orcid: https://orcid.org/0000-0002-5147-4711 - year: '2023' - version: '>= 1.1.3' + year: '2024' + version: '>= 1.2.0' - type: software title: performance abstract: 'performance: Assessment of Regression Models Performance' notes: Imports url: https://easystats.github.io/performance/ - repository: https://CRAN.R-project.org/package=performance + repository: https://easystats.r-universe.dev authors: - family-names: Lüdecke given-names: Daniel @@ -397,7 +397,7 @@ references: given-names: Brenton M. email: brenton@wiernik.org orcid: https://orcid.org/0000-0001-9560-6336 - year: '2023' + year: '2024' version: '>= 0.10.8' - type: software title: purrr @@ -413,7 +413,7 @@ references: - family-names: Henry given-names: Lionel email: lionel@rstudio.com - year: '2023' + year: '2024' version: '>= 1.0.2' - type: software title: rlang @@ -428,7 +428,7 @@ references: - family-names: Wickham given-names: Hadley email: hadley@posit.co - year: '2023' + year: '2024' - type: software title: stats abstract: 'R: A Language and Environment for Statistical Computing' @@ -437,7 +437,7 @@ references: - name: R Core Team location: name: Vienna, Austria - year: '2023' + year: '2024' institution: name: R Foundation for Statistical Computing - type: software @@ -451,8 +451,8 @@ references: given-names: Indrajeet email: patilindrajeet.science@gmail.com orcid: https://orcid.org/0000-0003-1995-6531 - year: '2023' - version: '>= 1.5.2.9000' + version: '>= 1.5.3' + year: '2024' - type: software title: tidyr abstract: 'tidyr: Tidy Messy Data' @@ -468,7 +468,7 @@ references: email: davis@posit.co - family-names: Girlich given-names: Maximilian - year: '2023' + year: '2024' version: '>= 1.3.0' - type: software title: utils @@ -478,7 +478,7 @@ references: - name: R Core Team location: name: Vienna, Austria - year: '2023' + year: '2024' institution: name: R Foundation for Statistical Computing - type: software @@ -501,7 +501,7 @@ references: orcid: https://orcid.org/0000-0003-4900-788X - family-names: Ben-Shachar given-names: Mattan S. - year: '2023' + year: '2024' - type: software title: BayesFactor abstract: 'BayesFactor: Computation of Bayes Factors for Common Designs' @@ -515,7 +515,7 @@ references: - family-names: Rouder given-names: Jeffrey N. email: jrouder@uci.edu - year: '2023' + year: '2024' version: '>= 0.9.12-4.5' - type: software title: gapminder @@ -528,7 +528,7 @@ references: given-names: Jennifer email: jenny@posit.co orcid: https://orcid.org/0000-0002-6983-2759 - year: '2023' + year: '2024' - type: software title: knitr abstract: 'knitr: A General-Purpose Package for Dynamic Report Generation in R' @@ -540,7 +540,7 @@ references: given-names: Yihui email: xie@yihui.name orcid: https://orcid.org/0000-0003-0645-5666 - year: '2023' + year: '2024' - type: software title: lme4 abstract: 'lme4: Linear Mixed-Effects Models using ''Eigen'' and S4' @@ -561,7 +561,8 @@ references: - family-names: Walker given-names: Steven orcid: https://orcid.org/0000-0002-4394-9078 - year: '2023' + year: '2024' + version: '>= 1.1-35.1' - type: software title: MASS abstract: 'MASS: Support Functions and Datasets for Venables and Ripley''s MASS' @@ -572,7 +573,7 @@ references: - family-names: Ripley given-names: Brian email: ripley@stats.ox.ac.uk - year: '2023' + year: '2024' - type: software title: metaBMA abstract: 'metaBMA: Bayesian Model Averaging for Random and Fixed Effects Meta-Analysis' @@ -584,7 +585,7 @@ references: given-names: Daniel W. email: daniel.heck@uni-marburg.de orcid: https://orcid.org/0000-0002-6302-9252 - year: '2023' + year: '2024' - type: software title: metafor abstract: 'metafor: Meta-Analysis Package for R' @@ -596,7 +597,7 @@ references: given-names: Wolfgang email: wvb@metafor-project.org orcid: https://orcid.org/0000-0003-3463-4063 - year: '2023' + year: '2024' - type: software title: metaplus abstract: 'metaplus: Robust Meta-Analysis and Meta-Regression' @@ -610,7 +611,7 @@ references: given-names: Ben email: bolker@mcmaster.ca - name: R Development Core Team - year: '2023' + year: '2024' - type: software title: PMCMRplus abstract: 'PMCMRplus: Calculate Pairwise Multiple Comparisons of Mean Rank Sums @@ -622,8 +623,8 @@ references: given-names: Thorsten email: thorsten.pohlert@gmx.de orcid: https://orcid.org/0000-0003-3855-3025 - year: '2023' - version: '>= 1.9.7' + year: '2024' + version: '>= 1.9.9' - type: software title: psych abstract: 'psych: Procedures for Psychological, Psychometric, and Personality Research' @@ -635,7 +636,10 @@ references: given-names: William email: revelle@northwestern.edu orcid: https://orcid.org/0000-0003-4880-9610 - year: '2023' + year: '2024' + identifiers: + - type: url + value: https://personality-project.org/r/psych-manual.pdf - type: software title: rmarkdown abstract: 'rmarkdown: Dynamic Documents for R' @@ -678,7 +682,26 @@ references: given-names: Richard email: rich@posit.co orcid: https://orcid.org/0000-0003-3925-190X - year: '2023' + year: '2024' +- type: software + title: rstantools + abstract: 'rstantools: Tools for Developing R Packages Interfacing with ''Stan''' + notes: Suggests + url: https://mc-stan.org/rstantools/ + repository: https://CRAN.R-project.org/package=rstantools + authors: + - family-names: Gabry + given-names: Jonah + email: jsg2201@columbia.edu + - family-names: Goodrich + given-names: Ben + email: benjamin.goodrich@columbia.edu + - family-names: Lysy + given-names: Martin + email: mlysy@uwaterloo.ca + - family-names: Johnson + given-names: Andrew + year: '2024' - type: software title: survival abstract: 'survival: Survival Analysis' @@ -689,7 +712,7 @@ references: - family-names: Therneau given-names: Terry M email: therneau.terry@mayo.edu - year: '2023' + year: '2024' - type: software title: testthat abstract: 'testthat: Unit Testing for R' @@ -700,8 +723,8 @@ references: - family-names: Wickham given-names: Hadley email: hadley@posit.co - year: '2023' - version: '>= 3.2.0' + year: '2024' + version: '>= 3.2.1' - type: software title: tibble abstract: 'tibble: Simple Data Frames' @@ -716,7 +739,7 @@ references: - family-names: Wickham given-names: Hadley email: hadley@rstudio.com - year: '2023' + year: '2024' - type: software title: vdiffr abstract: 'vdiffr: Visual Regression Testing and Graphical Diffing' @@ -740,7 +763,7 @@ references: - family-names: Lise given-names: Vaudor email: lise.vaudor@ens-lyon.fr - year: '2023' + year: '2024' version: '>= 1.0.7' - type: software title: withr @@ -765,7 +788,7 @@ references: email: hadley@rstudio.com - family-names: Chang given-names: Winston - year: '2023' + year: '2024' - type: software title: WRS2 abstract: 'WRS2: A Collection of Robust Statistical Methods' @@ -779,4 +802,4 @@ references: - family-names: Wilcox given-names: Rand email: rwilcox@usc.edu - year: '2023' + year: '2024' diff --git a/DESCRIPTION b/DESCRIPTION index fd5408e7c..70b2e5d04 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: ggstatsplot Title: 'ggplot2' Based Plots with Statistical Details -Version: 0.12.1.9000 +Version: 0.12.2 Authors@R: c(person(given = "Indrajeet", family = "Patil", @@ -32,23 +32,23 @@ Depends: R (>= 4.1.0) Imports: correlation (>= 0.8.4), - datawizard (>= 0.9.0), - dplyr (>= 1.1.3), + datawizard (>= 0.9.1), + dplyr (>= 1.1.4), ggcorrplot (>= 0.1.4.1), ggplot2 (>= 3.4.4), - ggrepel (>= 0.9.4), - ggside (>= 0.2.2), + ggrepel (>= 0.9.5), + ggside (>= 0.2.3), ggsignif (>= 0.6.4), glue, - insight (>= 0.19.6), + insight (>= 0.19.7), paletteer (>= 1.5.0), - parameters (>= 0.21.2), - patchwork (>= 1.1.3), + parameters (>= 0.21.3), + patchwork (>= 1.2.0), performance (>= 0.10.8), purrr (>= 1.0.2), rlang, stats, - statsExpressions (>= 1.5.2.9000), + statsExpressions (>= 1.5.3), tidyr (>= 1.3.0), utils Suggests: @@ -56,22 +56,21 @@ Suggests: BayesFactor (>= 0.9.12-4.5), gapminder, knitr, - lme4, + lme4 (>= 1.1-35.1), MASS, metaBMA, metafor, metaplus, - PMCMRplus (>= 1.9.7), + PMCMRplus (>= 1.9.9), psych, rmarkdown, + rstantools, survival, - testthat (>= 3.2.0), + testthat (>= 3.2.1), tibble, vdiffr (>= 1.0.7), withr, WRS2 -Remotes: - IndrajeetPatil/statsExpressions VignetteBuilder: knitr Encoding: UTF-8 @@ -81,7 +80,7 @@ Roxygen: list( markdown = TRUE, roclets = c("collate", "namespace", "rd", "pkgapi::api_roclet", "roxyglobals::global_roclet") ) -RoxygenNote: 7.2.3.9000 +RoxygenNote: 7.3.0 Config/testthat/edition: 3 Config/testthat/parallel: true Config/Needs/check: anthonynorth/roxyglobals diff --git a/NEWS.md b/NEWS.md index 792589284..9af3c2c4b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,10 +1,14 @@ -# ggstatsplot 0.12.1 +# ggstatsplot 0.12.2 N.B. All statistical analysis in `{ggstatsplot}` is carried out in `{statsExpressions}`. Thus, to see changes related to statistical expressions, read the `NEWS` for that package: +- No user-visible changes. Maintenance-only release. + +# ggstatsplot 0.12.1 + ## MINOR CHANGES - Maintenance updates for changes in upstream dependencies. diff --git a/R/combine_plots.R b/R/combine-plots.R similarity index 90% rename from R/combine_plots.R rename to R/combine-plots.R index 1add5b1eb..bcaa772d5 100644 --- a/R/combine_plots.R +++ b/R/combine-plots.R @@ -57,11 +57,12 @@ #' ) #' ) #' @export -combine_plots <- function(plotlist, - plotgrid.args = list(), - annotation.args = list(), - guides = "collect", - ...) { +combine_plots <- function( + plotlist, + plotgrid.args = list(), + annotation.args = list(), + guides = "collect", + ...) { exec(patchwork::wrap_plots, !!!plotlist, guides = guides, !!!plotgrid.args) + exec(patchwork::plot_annotation, !!!annotation.args) } diff --git a/R/extract_stats.R b/R/extract-stats.R similarity index 92% rename from R/extract_stats.R rename to R/extract-stats.R index 849476fd7..a1c4bfcc5 100644 --- a/R/extract_stats.R +++ b/R/extract-stats.R @@ -65,8 +65,8 @@ extract_stats <- function(p, ...) { #' @rdname extract_stats #' @export -extract_subtitle <- function(p) extract_stats(p)$subtitle_data$expression[[1L]] +extract_subtitle <- function(p) purrr::pluck(extract_stats(p), "subtitle_data", "expression", 1L) #' @rdname extract_stats #' @export -extract_caption <- function(p) extract_stats(p)$caption_data$expression[[1L]] +extract_caption <- function(p) purrr::pluck(extract_stats(p), "caption_data", "expression", 1L) diff --git a/R/ggbarstats.R b/R/ggbarstats.R index c64596e05..bc58c5838 100644 --- a/R/ggbarstats.R +++ b/R/ggbarstats.R @@ -38,36 +38,37 @@ #' # extracting details from statistical tests #' extract_stats(p) #' @export -ggbarstats <- function(data, - x, - y, - counts = NULL, - type = "parametric", - paired = FALSE, - results.subtitle = TRUE, - label = "percentage", - label.args = list(alpha = 1.0, fill = "white"), - sample.size.label.args = list(size = 4.0), - k = 2L, - proportion.test = results.subtitle, - perc.k = 0L, - bf.message = TRUE, - ratio = NULL, - conf.level = 0.95, - sampling.plan = "indepMulti", - fixed.margin = "rows", - prior.concentration = 1.0, - title = NULL, - subtitle = NULL, - caption = NULL, - legend.title = NULL, - xlab = NULL, - ylab = NULL, - ggtheme = ggstatsplot::theme_ggstatsplot(), - package = "RColorBrewer", - palette = "Dark2", - ggplot.component = NULL, - ...) { +ggbarstats <- function( + data, + x, + y, + counts = NULL, + type = "parametric", + paired = FALSE, + results.subtitle = TRUE, + label = "percentage", + label.args = list(alpha = 1.0, fill = "white"), + sample.size.label.args = list(size = 4.0), + k = 2L, + proportion.test = results.subtitle, + perc.k = 0L, + bf.message = TRUE, + ratio = NULL, + conf.level = 0.95, + sampling.plan = "indepMulti", + fixed.margin = "rows", + prior.concentration = 1.0, + title = NULL, + subtitle = NULL, + caption = NULL, + legend.title = NULL, + xlab = NULL, + ylab = NULL, + ggtheme = ggstatsplot::theme_ggstatsplot(), + package = "RColorBrewer", + palette = "Dark2", + ggplot.component = NULL, + ...) { # data frame ------------------------------------------ type <- stats_type_switch(type) @@ -86,7 +87,7 @@ ggbarstats <- function(data, data %<>% mutate(across(.cols = everything(), .fns = ~ droplevels(as.factor(.x)))) # TO DO: until one-way table is supported by `BayesFactor` - if (nlevels(data %>% pull({{ y }})) == 1L) c(bf.message, proportion.test) %<-% c(FALSE, FALSE) + if (nlevels(pull(data, {{ y }})) == 1L) c(bf.message, proportion.test) %<-% c(FALSE, FALSE) if (type == "bayes") proportion.test <- FALSE # statistical analysis ------------------------------------------ @@ -124,7 +125,7 @@ ggbarstats <- function(data, onesample_df <- onesample_data(data, {{ x }}, {{ y }}, k) # if no. of factor levels is greater than the default palette color count - .is_palette_sufficient(package, palette, nlevels(data %>% pull({{ x }}))) + .is_palette_sufficient(package, palette, nlevels(pull(data, {{ x }}))) # plot plotBar <- ggplot(descriptive_df, aes({{ y }}, perc, fill = {{ x }})) + @@ -222,11 +223,12 @@ ggbarstats <- function(data, #' plotgrid.args = list(nrow = 2) #' ) #' @export -grouped_ggbarstats <- function(data, - ..., - grouping.var, - plotgrid.args = list(), - annotation.args = list()) { +grouped_ggbarstats <- function( + data, + ..., + grouping.var, + plotgrid.args = list(), + annotation.args = list()) { .grouped_list(data, {{ grouping.var }}) %>% purrr::pmap(.f = ggbarstats, ...) %>% combine_plots(plotgrid.args, annotation.args) diff --git a/R/ggbetweenstats_helpers.R b/R/ggbetweenstats-helpers.R similarity index 78% rename from R/ggbetweenstats_helpers.R rename to R/ggbetweenstats-helpers.R index 526c0b83f..e03340a60 100644 --- a/R/ggbetweenstats_helpers.R +++ b/R/ggbetweenstats-helpers.R @@ -26,23 +26,24 @@ #' y = Sepal.Length #' ) #' @noRd -.centrality_ggrepel <- function(plot, - data, - x, - y, - centrality.path = FALSE, - centrality.path.args = list( - linewidth = 1.0, - color = "red", - alpha = 0.5 - ), - centrality.point.args = list(size = 5.0, color = "darkred"), - centrality.label.args = list( - size = 3.0, - nudge_x = 0.4, - segment.linetype = 4.0 - ), - ...) { +.centrality_ggrepel <- function( + plot, + data, + x, + y, + centrality.path = FALSE, + centrality.path.args = list( + linewidth = 1.0, + color = "red", + alpha = 0.5 + ), + centrality.point.args = list(size = 5.0, color = "darkred"), + centrality.label.args = list( + size = 3.0, + nudge_x = 0.4, + segment.linetype = 4.0 + ), + ...) { centrality_df <- suppressWarnings(centrality_description(data, {{ x }}, {{ y }}, ...)) # lines connecting mean values across groups @@ -111,14 +112,15 @@ #' mpc_df = df_pair #' ) #' @noRd -.ggsignif_adder <- function(plot, - data, - x, - y, - mpc_df, - pairwise.display = "significant", - ggsignif.args = list(textsize = 3, tip_length = 0.01, na.rm = TRUE), - ...) { +.ggsignif_adder <- function( + plot, + data, + x, + y, + mpc_df, + pairwise.display = "significant", + ggsignif.args = list(textsize = 3, tip_length = 0.01, na.rm = TRUE), + ...) { # creating a column for group combinations mpc_df %<>% mutate(groups = purrr::pmap(.l = list(group1, group2), .f = c)) @@ -221,19 +223,20 @@ #' @param ... Additional arguments. #' #' @noRd -.aesthetic_addon <- function(plot, - x, - xlab = NULL, - ylab = NULL, - title = NULL, - subtitle = NULL, - caption = NULL, - seclabel = NULL, - ggtheme = ggstatsplot::theme_ggstatsplot(), - package = "RColorBrewer", - palette = "Dark2", - ggplot.component = NULL, - ...) { +.aesthetic_addon <- function( + plot, + x, + xlab = NULL, + ylab = NULL, + title = NULL, + subtitle = NULL, + caption = NULL, + seclabel = NULL, + ggtheme = ggstatsplot::theme_ggstatsplot(), + package = "RColorBrewer", + palette = "Dark2", + ggplot.component = NULL, + ...) { # if no. of factor levels is greater than the default palette color count .is_palette_sufficient(package, palette, nlevels(x)) diff --git a/R/ggbetweenstats.R b/R/ggbetweenstats.R index 588801229..feff33b27 100644 --- a/R/ggbetweenstats.R +++ b/R/ggbetweenstats.R @@ -132,59 +132,62 @@ #' #' # you can remove a specific geom to reduce complexity of the plot #' ggbetweenstats( -#' mtcars, am, wt, +#' mtcars, +#' am, +#' wt, #' # to remove violin plot -#' violin.args = list(width = 0), +#' violin.args = list(width = 0, linewidth = 0), #' # to remove boxplot #' boxplot.args = list(width = 0), #' # to remove points #' point.args = list(alpha = 0) #' ) #' @export -ggbetweenstats <- function(data, - x, - y, - type = "parametric", - pairwise.display = "significant", - p.adjust.method = "holm", - effsize.type = "unbiased", - bf.prior = 0.707, - bf.message = TRUE, - results.subtitle = TRUE, - xlab = NULL, - ylab = NULL, - caption = NULL, - title = NULL, - subtitle = NULL, - k = 2L, - var.equal = FALSE, - conf.level = 0.95, - nboot = 100L, - tr = 0.2, - centrality.plotting = TRUE, - centrality.type = type, - centrality.point.args = list(size = 5, color = "darkred"), - centrality.label.args = list( - size = 3, - nudge_x = 0.4, - segment.linetype = 4, - min.segment.length = 0 - ), - point.args = list( - position = ggplot2::position_jitterdodge(dodge.width = 0.60), - alpha = 0.4, - size = 3, - stroke = 0, - na.rm = TRUE - ), - boxplot.args = list(width = 0.3, alpha = 0.2, na.rm = TRUE), - violin.args = list(width = 0.5, alpha = 0.2, na.rm = TRUE), - ggsignif.args = list(textsize = 3, tip_length = 0.01, na.rm = TRUE), - ggtheme = ggstatsplot::theme_ggstatsplot(), - package = "RColorBrewer", - palette = "Dark2", - ggplot.component = NULL, - ...) { +ggbetweenstats <- function( + data, + x, + y, + type = "parametric", + pairwise.display = "significant", + p.adjust.method = "holm", + effsize.type = "unbiased", + bf.prior = 0.707, + bf.message = TRUE, + results.subtitle = TRUE, + xlab = NULL, + ylab = NULL, + caption = NULL, + title = NULL, + subtitle = NULL, + k = 2L, + var.equal = FALSE, + conf.level = 0.95, + nboot = 100L, + tr = 0.2, + centrality.plotting = TRUE, + centrality.type = type, + centrality.point.args = list(size = 5, color = "darkred"), + centrality.label.args = list( + size = 3, + nudge_x = 0.4, + segment.linetype = 4, + min.segment.length = 0 + ), + point.args = list( + position = ggplot2::position_jitterdodge(dodge.width = 0.60), + alpha = 0.4, + size = 3, + stroke = 0, + na.rm = TRUE + ), + boxplot.args = list(width = 0.3, alpha = 0.2, na.rm = TRUE), + violin.args = list(width = 0.5, alpha = 0.2, na.rm = TRUE), + ggsignif.args = list(textsize = 3, tip_length = 0.01, na.rm = TRUE), + ggtheme = ggstatsplot::theme_ggstatsplot(), + package = "RColorBrewer", + palette = "Dark2", + ggplot.component = NULL, + ...) { # data ----------------------------------- @@ -200,8 +203,7 @@ ggbetweenstats <- function(data, # statistical analysis ------------------------------------------ - # test to run; depends on the no. of levels of the independent variable - test <- ifelse(nlevels(data %>% pull({{ x }})) < 3L, "t", "anova") + test <- ifelse(nlevels(pull(data, {{ x }})) < 3L, "t", "anova") if (results.subtitle) { .f.args <- list( @@ -230,7 +232,7 @@ ggbetweenstats <- function(data, # plot ----------------------------------- - plot <- ggplot(data, mapping = aes({{ x }}, {{ y }})) + + plot_comparison <- ggplot(data, mapping = aes({{ x }}, {{ y }})) + exec(geom_point, aes(color = {{ x }}), !!!point.args) + exec(geom_boxplot, !!!boxplot.args, outlier.shape = NA) + exec(geom_violin, !!!violin.args) @@ -238,8 +240,8 @@ ggbetweenstats <- function(data, # centrality tagging ------------------------------------- if (isTRUE(centrality.plotting)) { - plot <- suppressWarnings(.centrality_ggrepel( - plot = plot, + plot_comparison <- suppressWarnings(.centrality_ggrepel( + plot = plot_comparison, data = data, x = {{ x }}, y = {{ y }}, @@ -269,8 +271,8 @@ ggbetweenstats <- function(data, ) # adding the layer for pairwise comparisons - plot <- .ggsignif_adder( - plot = plot, + plot_comparison <- .ggsignif_adder( + plot = plot_comparison, mpc_df = mpc_df, data = data, x = {{ x }}, @@ -286,8 +288,8 @@ ggbetweenstats <- function(data, # annotations ------------------------ .aesthetic_addon( - plot = plot, - x = data %>% pull({{ x }}), + plot = plot_comparison, + x = pull(data, {{ x }}), xlab = xlab %||% as_name(x), ylab = ylab %||% as_name(y), title = title, @@ -355,11 +357,12 @@ ggbetweenstats <- function(data, #' ) #' ) #' @export -grouped_ggbetweenstats <- function(data, - ..., - grouping.var, - plotgrid.args = list(), - annotation.args = list()) { +grouped_ggbetweenstats <- function( + data, + ..., + grouping.var, + plotgrid.args = list(), + annotation.args = list()) { .grouped_list(data, {{ grouping.var }}) %>% purrr::pmap(.f = ggbetweenstats, ...) %>% combine_plots(plotgrid.args, annotation.args) diff --git a/R/ggcoefstats.R b/R/ggcoefstats.R index 074bfd926..7e03b7e8b 100644 --- a/R/ggcoefstats.R +++ b/R/ggcoefstats.R @@ -116,39 +116,40 @@ #' # further arguments can be passed to `parameters::model_parameters()` #' ggcoefstats(lmer(Reaction ~ Days + (Days | Subject), sleepstudy), effects = "fixed") #' @export -ggcoefstats <- function(x, - statistic = NULL, - conf.int = TRUE, - conf.level = 0.95, - k = 2L, - exclude.intercept = FALSE, - effectsize.type = "eta", - meta.analytic.effect = FALSE, - meta.type = "parametric", - bf.message = TRUE, - sort = "none", - xlab = NULL, - ylab = NULL, - title = NULL, - subtitle = NULL, - caption = NULL, - only.significant = FALSE, - point.args = list(size = 3.0, color = "blue", na.rm = TRUE), - errorbar.args = list(height = 0, na.rm = TRUE), - vline = TRUE, - vline.args = list(linewidth = 1.0, linetype = "dashed"), - stats.labels = TRUE, - stats.label.color = NULL, - stats.label.args = list( - size = 3.0, - direction = "y", - min.segment.length = 0, - na.rm = TRUE - ), - package = "RColorBrewer", - palette = "Dark2", - ggtheme = ggstatsplot::theme_ggstatsplot(), - ...) { +ggcoefstats <- function( + x, + statistic = NULL, + conf.int = TRUE, + conf.level = 0.95, + k = 2L, + exclude.intercept = FALSE, + effectsize.type = "eta", + meta.analytic.effect = FALSE, + meta.type = "parametric", + bf.message = TRUE, + sort = "none", + xlab = NULL, + ylab = NULL, + title = NULL, + subtitle = NULL, + caption = NULL, + only.significant = FALSE, + point.args = list(size = 3.0, color = "blue", na.rm = TRUE), + errorbar.args = list(height = 0, na.rm = TRUE), + vline = TRUE, + vline.args = list(linewidth = 1.0, linetype = "dashed"), + stats.labels = TRUE, + stats.label.color = NULL, + stats.label.args = list( + size = 3.0, + direction = "y", + min.segment.length = 0, + na.rm = TRUE + ), + package = "RColorBrewer", + palette = "Dark2", + ggtheme = ggstatsplot::theme_ggstatsplot(), + ...) { # model check ------------------------- # if a data frame is entered then `statistic` is necessary to create labels @@ -260,12 +261,12 @@ ggcoefstats <- function(x, # basic plot ------------------------- - plot <- ggplot(tidy_df, mapping = aes(estimate, term)) + + plot_coef <- ggplot(tidy_df, mapping = aes(estimate, term)) + exec(geom_point, !!!point.args) # adding confidence intervals if (conf.int) { - plot <- plot + + plot_coef <- plot_coef + exec( geom_errorbarh, data = tidy_df, @@ -275,7 +276,7 @@ ggcoefstats <- function(x, } # adding the vertical line - if (vline) plot <- plot + exec(geom_vline, xintercept = 0, !!!vline.args) + if (vline) plot_coef <- plot_coef + exec(geom_vline, xintercept = 0, !!!vline.args) # ggrepel labels ------------------------- @@ -284,7 +285,7 @@ ggcoefstats <- function(x, stats.label.color <- paletteer::paletteer_d(paste0(package, "::", palette), length(tidy_df$term)) } - plot <- plot + + plot_coef <- plot_coef + exec( ggrepel::geom_label_repel, data = tidy_df, @@ -297,7 +298,7 @@ ggcoefstats <- function(x, # annotations ------------------------- - plot + + plot_coef + labs( x = xlab %||% "estimate", y = ylab %||% "term", diff --git a/R/ggcorrmat.R b/R/ggcorrmat.R index 742df8b0e..214a361eb 100644 --- a/R/ggcorrmat.R +++ b/R/ggcorrmat.R @@ -59,29 +59,30 @@ #' library(ggcorrplot) #' ggcorrmat(iris) #' @export -ggcorrmat <- function(data, - cor.vars = NULL, - cor.vars.names = NULL, - matrix.type = "upper", - type = "parametric", - tr = 0.2, - partial = FALSE, - k = 2L, - sig.level = 0.05, - conf.level = 0.95, - bf.prior = 0.707, - p.adjust.method = "holm", - pch = "cross", - ggcorrplot.args = list(method = "square", outline.color = "black", pch.cex = 14), - package = "RColorBrewer", - palette = "Dark2", - colors = c("#E69F00", "white", "#009E73"), - ggtheme = ggstatsplot::theme_ggstatsplot(), - ggplot.component = NULL, - title = NULL, - subtitle = NULL, - caption = NULL, - ...) { +ggcorrmat <- function( + data, + cor.vars = NULL, + cor.vars.names = NULL, + matrix.type = "upper", + type = "parametric", + tr = 0.2, + partial = FALSE, + k = 2L, + sig.level = 0.05, + conf.level = 0.95, + bf.prior = 0.707, + p.adjust.method = "holm", + pch = "cross", + ggcorrplot.args = list(method = "square", outline.color = "black", pch.cex = 14), + package = "RColorBrewer", + palette = "Dark2", + colors = c("#E69F00", "white", "#009E73"), + ggtheme = ggstatsplot::theme_ggstatsplot(), + ggplot.component = NULL, + title = NULL, + subtitle = NULL, + caption = NULL, + ...) { type <- stats_type_switch(type) if (!missing(cor.vars)) data <- select(data, {{ cor.vars }}) @@ -126,7 +127,7 @@ ggcorrmat <- function(data, )) } - plot <- exec( + plot_corr <- exec( ggcorrplot::ggcorrplot, corr = as.matrix(select(mpc_df, matches("^parameter|^r"))), p.mat = as.matrix(select(mpc_df, matches("^parameter|^p"))), @@ -162,7 +163,7 @@ ggcorrmat <- function(data, # annotations ------------------------------------------ - plot + + plot_corr + theme( panel.grid.major = element_blank(), panel.grid.minor = element_blank(), @@ -213,11 +214,12 @@ ggcorrmat <- function(data, #' annotation.args = list(tag_levels = "i") #' ) #' @export -grouped_ggcorrmat <- function(data, - ..., - grouping.var, - plotgrid.args = list(), - annotation.args = list()) { +grouped_ggcorrmat <- function( + data, + ..., + grouping.var, + plotgrid.args = list(), + annotation.args = list()) { .grouped_list(data, {{ grouping.var }}) %>% purrr::pmap(.f = ggcorrmat, ...) %>% # `guides = "keep"` because legends can be different across grouping levels diff --git a/R/ggdotplotstats.R b/R/ggdotplotstats.R index 68f8cab09..464054f3f 100644 --- a/R/ggdotplotstats.R +++ b/R/ggdotplotstats.R @@ -47,30 +47,31 @@ #' # extracting details from statistical tests #' extract_stats(p) #' @export -ggdotplotstats <- function(data, - x, - y, - xlab = NULL, - ylab = NULL, - title = NULL, - subtitle = NULL, - caption = NULL, - type = "parametric", - test.value = 0, - bf.prior = 0.707, - bf.message = TRUE, - effsize.type = "g", - conf.level = 0.95, - tr = 0.2, - k = 2L, - results.subtitle = TRUE, - point.args = list(color = "black", size = 3, shape = 16), - centrality.plotting = TRUE, - centrality.type = type, - centrality.line.args = list(color = "blue", linewidth = 1, linetype = "dashed"), - ggplot.component = NULL, - ggtheme = ggstatsplot::theme_ggstatsplot(), - ...) { +ggdotplotstats <- function( + data, + x, + y, + xlab = NULL, + ylab = NULL, + title = NULL, + subtitle = NULL, + caption = NULL, + type = "parametric", + test.value = 0, + bf.prior = 0.707, + bf.message = TRUE, + effsize.type = "g", + conf.level = 0.95, + tr = 0.2, + k = 2L, + results.subtitle = TRUE, + point.args = list(color = "black", size = 3, shape = 16), + centrality.plotting = TRUE, + centrality.type = type, + centrality.line.args = list(color = "blue", linewidth = 1, linetype = "dashed"), + ggplot.component = NULL, + ggtheme = ggstatsplot::theme_ggstatsplot(), + ...) { # data ----------------------------------- @@ -116,11 +117,11 @@ ggdotplotstats <- function(data, # plot ----------------------------------- - plot <- ggplot(data, mapping = aes({{ x }}, y = rank)) + + plot_dot <- ggplot(data, mapping = aes({{ x }}, y = rank)) + exec(geom_point, !!!point.args) + scale_y_continuous( name = ylab, - labels = data %>% pull({{ y }}), + labels = pull(data, {{ y }}), breaks = data$rank, sec.axis = dup_axis( name = "percentile", @@ -132,9 +133,9 @@ ggdotplotstats <- function(data, # centrality plotting ------------------------------------- if (isTRUE(centrality.plotting)) { - plot <- .histo_labeller( - plot, - x = data %>% pull({{ x }}), + plot_dot <- .histo_labeller( + plot_dot, + x = pull(data, {{ x }}), type = stats_type_switch(centrality.type), tr = tr, k = k, @@ -144,7 +145,7 @@ ggdotplotstats <- function(data, # annotations ------------------------- - plot + + plot_dot + labs( x = xlab %||% as_name(x), y = ylab %||% as_name(y), @@ -195,11 +196,12 @@ ggdotplotstats <- function(data, #' test.value = 15.5 #' ) #' @export -grouped_ggdotplotstats <- function(data, - ..., - grouping.var, - plotgrid.args = list(), - annotation.args = list()) { +grouped_ggdotplotstats <- function( + data, + ..., + grouping.var, + plotgrid.args = list(), + annotation.args = list()) { .grouped_list(data, {{ grouping.var }}) %>% purrr::pmap(.f = ggdotplotstats, ...) %>% combine_plots(plotgrid.args, annotation.args) diff --git a/R/gghistostats_helpers.R b/R/gghistostats-helpers.R similarity index 100% rename from R/gghistostats_helpers.R rename to R/gghistostats-helpers.R diff --git a/R/gghistostats.R b/R/gghistostats.R index 4ff32b26b..363841a9a 100644 --- a/R/gghistostats.R +++ b/R/gghistostats.R @@ -58,45 +58,43 @@ #' # extracting details from statistical tests #' extract_stats(p) #' @export -gghistostats <- function(data, - x, - binwidth = NULL, - xlab = NULL, - title = NULL, - subtitle = NULL, - caption = NULL, - type = "parametric", - test.value = 0, - bf.prior = 0.707, - bf.message = TRUE, - effsize.type = "g", - conf.level = 0.95, - tr = 0.2, - k = 2L, - ggtheme = ggstatsplot::theme_ggstatsplot(), - results.subtitle = TRUE, - bin.args = list(color = "black", fill = "grey50", alpha = 0.7), - centrality.plotting = TRUE, - centrality.type = type, - centrality.line.args = list(color = "blue", linewidth = 1, linetype = "dashed"), - normal.curve = FALSE, - normal.curve.args = list(linewidth = 2), - ggplot.component = NULL, - ...) { +gghistostats <- function( + data, + x, + binwidth = NULL, + xlab = NULL, + title = NULL, + subtitle = NULL, + caption = NULL, + type = "parametric", + test.value = 0, + bf.prior = 0.707, + bf.message = TRUE, + effsize.type = "g", + conf.level = 0.95, + tr = 0.2, + k = 2L, + ggtheme = ggstatsplot::theme_ggstatsplot(), + results.subtitle = TRUE, + bin.args = list(color = "black", fill = "grey50", alpha = 0.7), + centrality.plotting = TRUE, + centrality.type = type, + centrality.line.args = list(color = "blue", linewidth = 1, linetype = "dashed"), + normal.curve = FALSE, + normal.curve.args = list(linewidth = 2), + ggplot.component = NULL, + ...) { # data ----------------------------------- x <- ensym(x) data <- tidyr::drop_na(select(data, {{ x }})) - - # extract a vector for convenience - x_vec <- data %>% pull({{ x }}) + x_vec <- pull(data, {{ x }}) # statistical analysis ------------------------------------------ if (results.subtitle) { type <- stats_type_switch(type) - .f.args <- list( data = data, x = {{ x }}, @@ -121,7 +119,7 @@ gghistostats <- function(data, # plot ----------------------------------- - plot <- ggplot(data, mapping = aes(x = {{ x }})) + + plot_hist <- ggplot(data, mapping = aes(x = {{ x }})) + exec( stat_bin, mapping = aes(y = after_stat(count), fill = after_stat(count)), @@ -139,7 +137,7 @@ gghistostats <- function(data, # if normal curve overlay needs to be displayed if (normal.curve) { - plot <- plot + + plot_hist <- plot_hist + exec( stat_function, fun = function(x, mean, sd, n, bw) stats::dnorm(x, mean, sd) * n * bw, @@ -151,8 +149,8 @@ gghistostats <- function(data, # centrality plotting ------------------------------------- if (isTRUE(centrality.plotting)) { - plot <- .histo_labeller( - plot, + plot_hist <- .histo_labeller( + plot_hist, x = x_vec, type = stats_type_switch(centrality.type), tr = tr, @@ -163,7 +161,7 @@ gghistostats <- function(data, # annotations ------------------------------- - plot + + plot_hist + labs( x = xlab %||% as_name(x), y = "count", @@ -215,18 +213,19 @@ gghistostats <- function(data, #' annotation.args = list(tag_levels = "i") #' ) #' @export -grouped_gghistostats <- function(data, - x, - grouping.var, - binwidth = NULL, - plotgrid.args = list(), - annotation.args = list(), - ...) { +grouped_gghistostats <- function( + data, + x, + grouping.var, + binwidth = NULL, + plotgrid.args = list(), + annotation.args = list(), + ...) { .grouped_list(data, {{ grouping.var }}) %>% purrr::pmap( .f = gghistostats, x = {{ x }}, - binwidth = binwidth %||% .binwidth(data %>% pull({{ x }})), + binwidth = binwidth %||% .binwidth(pull(data, {{ x }})), ... ) %>% combine_plots(plotgrid.args, annotation.args) diff --git a/R/ggpiestats_ggbarstats_helpers.R b/R/ggpiestats-ggbarstats-helpers.R similarity index 83% rename from R/ggpiestats_ggbarstats_helpers.R rename to R/ggpiestats-ggbarstats-helpers.R index 572c19134..f9249e7c6 100644 --- a/R/ggpiestats_ggbarstats_helpers.R +++ b/R/ggpiestats-ggbarstats-helpers.R @@ -1,21 +1,22 @@ #' @title A data frame with descriptive labels #' @autoglobal #' @noRd -descriptive_data <- function(data, - x, - y = NULL, - label.content = "percentage", - perc.k = 1L, - ...) { +descriptive_data <- function( + data, + x, + y = NULL, + label.content = "percentage", + perc.k = 1L, + ...) { .cat_counter(data, {{ x }}, {{ y }}) %>% mutate( .label = case_when( grepl("perc|prop", label.content) ~ paste0(round(perc, perc.k), "%"), grepl("count|n|N", label.content) ~ .prettyNum(counts), .default = paste0(.prettyNum(counts), "\n", "(", round(perc, perc.k), "%)") - ) - ) %>% # reorder the category factor levels to order the legend - mutate({{ x }} := factor({{ x }}, unique({{ x }}))) + ), # reorder the category factor levels to order the legend + {{ x }} := factor({{ x }}, unique({{ x }})) + ) } @@ -60,7 +61,7 @@ onesample_data <- function(data, x, y, k = 2L, ...) { #' @autoglobal #' @noRd .chisq_test_safe <- function(data, x, ...) { - xtab <- table(data %>% pull({{ x }})) + xtab <- table(pull(data, {{ x }})) result <- tryCatch( expr = parameters::model_parameters(suppressWarnings(stats::chisq.test(xtab))), diff --git a/R/ggpiestats.R b/R/ggpiestats.R index 3985e3389..c9102232b 100644 --- a/R/ggpiestats.R +++ b/R/ggpiestats.R @@ -63,34 +63,35 @@ #' ggpiestats(mtcars, vs, cyl) #' #' @export -ggpiestats <- function(data, - x, - y = NULL, - counts = NULL, - type = "parametric", - paired = FALSE, - results.subtitle = TRUE, - label = "percentage", - label.args = list(direction = "both"), - label.repel = FALSE, - k = 2L, - proportion.test = results.subtitle, - perc.k = 0L, - bf.message = TRUE, - ratio = NULL, - conf.level = 0.95, - sampling.plan = "indepMulti", - fixed.margin = "rows", - prior.concentration = 1, - title = NULL, - subtitle = NULL, - caption = NULL, - legend.title = NULL, - ggtheme = ggstatsplot::theme_ggstatsplot(), - package = "RColorBrewer", - palette = "Dark2", - ggplot.component = NULL, - ...) { +ggpiestats <- function( + data, + x, + y = NULL, + counts = NULL, + type = "parametric", + paired = FALSE, + results.subtitle = TRUE, + label = "percentage", + label.args = list(direction = "both"), + label.repel = FALSE, + k = 2L, + proportion.test = results.subtitle, + perc.k = 0L, + bf.message = TRUE, + ratio = NULL, + conf.level = 0.95, + sampling.plan = "indepMulti", + fixed.margin = "rows", + prior.concentration = 1, + title = NULL, + subtitle = NULL, + caption = NULL, + legend.title = NULL, + ggtheme = ggstatsplot::theme_ggstatsplot(), + package = "RColorBrewer", + palette = "Dark2", + ggplot.component = NULL, + ...) { # data frame ------------------------------------------ type <- stats_type_switch(type) @@ -111,8 +112,8 @@ ggpiestats <- function(data, # 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)))) - x_levels <- nlevels(data %>% pull({{ x }})) - y_levels <- ifelse(test == "one.way", 0L, nlevels(data %>% pull({{ y }}))) + x_levels <- nlevels(pull(data, {{ x }})) + y_levels <- ifelse(test == "one.way", 0L, nlevels(pull(data, {{ y }}))) # TODO: one-way table in `BayesFactor` (richarddmorey/BayesFactor#159) if (test == "two.way" && y_levels == 1L) bf.message <- FALSE @@ -249,11 +250,12 @@ ggpiestats <- function(data, #' # grouped one-sample proportion test #' grouped_ggpiestats(mtcars, x = cyl, grouping.var = am) #' @export -grouped_ggpiestats <- function(data, - ..., - grouping.var, - plotgrid.args = list(), - annotation.args = list()) { +grouped_ggpiestats <- function( + data, + ..., + grouping.var, + plotgrid.args = list(), + annotation.args = list()) { .grouped_list(data, {{ grouping.var }}) %>% purrr::pmap(.f = ggpiestats, ...) %>% combine_plots(plotgrid.args, annotation.args) diff --git a/R/ggscatterstats.R b/R/ggscatterstats.R index b271f0fc6..abc8b8c5a 100644 --- a/R/ggscatterstats.R +++ b/R/ggscatterstats.R @@ -77,34 +77,35 @@ #' extract_stats(p) #' #' @export -ggscatterstats <- function(data, - x, - y, - type = "parametric", - conf.level = 0.95, - bf.prior = 0.707, - bf.message = TRUE, - tr = 0.2, - k = 2L, - results.subtitle = TRUE, - label.var = NULL, - label.expression = NULL, - marginal = TRUE, - point.args = list(size = 3, alpha = 0.4, stroke = 0), - point.width.jitter = 0, - point.height.jitter = 0, - point.label.args = list(size = 3, max.overlaps = 1e6), - smooth.line.args = list(linewidth = 1.5, color = "blue", method = "lm", formula = y ~ x), - xsidehistogram.args = list(fill = "#009E73", color = "black", na.rm = TRUE), - ysidehistogram.args = list(fill = "#D55E00", color = "black", na.rm = TRUE), - xlab = NULL, - ylab = NULL, - title = NULL, - subtitle = NULL, - caption = NULL, - ggtheme = ggstatsplot::theme_ggstatsplot(), - ggplot.component = NULL, - ...) { +ggscatterstats <- function( + data, + x, + y, + type = "parametric", + conf.level = 0.95, + bf.prior = 0.707, + bf.message = TRUE, + tr = 0.2, + k = 2L, + results.subtitle = TRUE, + label.var = NULL, + label.expression = NULL, + marginal = TRUE, + point.args = list(size = 3, alpha = 0.4, stroke = 0), + point.width.jitter = 0, + point.height.jitter = 0, + point.label.args = list(size = 3, max.overlaps = 1e6), + smooth.line.args = list(linewidth = 1.5, color = "blue", method = "lm", formula = y ~ x), + xsidehistogram.args = list(fill = "#009E73", color = "black", na.rm = TRUE), + ysidehistogram.args = list(fill = "#D55E00", color = "black", na.rm = TRUE), + xlab = NULL, + ylab = NULL, + title = NULL, + subtitle = NULL, + caption = NULL, + ggtheme = ggstatsplot::theme_ggstatsplot(), + ggplot.component = NULL, + ...) { # data --------------------------------------- # ensure the arguments work quoted or unquoted @@ -258,11 +259,12 @@ ggscatterstats <- function(data, #' annotation.args = list(tag_levels = "a") #' ) #' @export -grouped_ggscatterstats <- function(data, - ..., - grouping.var, - plotgrid.args = list(), - annotation.args = list()) { +grouped_ggscatterstats <- function( + data, + ..., + grouping.var, + plotgrid.args = list(), + annotation.args = list()) { .grouped_list(data, {{ grouping.var }}) %>% purrr::pmap(.f = ggscatterstats, ...) %>% combine_plots(plotgrid.args, annotation.args) diff --git a/R/ggwithinstats.R b/R/ggwithinstats.R index 02f418a6c..00f582b77 100644 --- a/R/ggwithinstats.R +++ b/R/ggwithinstats.R @@ -71,49 +71,50 @@ #' x = condition, #' y = desire, #' # to remove violin plot -#' violin.args = list(width = 0), +#' violin.args = list(width = 0, linewidth = 0), #' # to remove boxplot #' boxplot.args = list(width = 0), #' # to remove points #' point.args = list(alpha = 0) #' ) #' @export -ggwithinstats <- function(data, - x, - y, - type = "parametric", - pairwise.display = "significant", - p.adjust.method = "holm", - effsize.type = "unbiased", - bf.prior = 0.707, - bf.message = TRUE, - results.subtitle = TRUE, - xlab = NULL, - ylab = NULL, - caption = NULL, - title = NULL, - subtitle = NULL, - k = 2L, - conf.level = 0.95, - nboot = 100L, - tr = 0.2, - centrality.plotting = TRUE, - centrality.type = type, - centrality.point.args = list(size = 5, color = "darkred"), - centrality.label.args = list(size = 3, nudge_x = 0.4, segment.linetype = 4), - centrality.path = TRUE, - centrality.path.args = list(linewidth = 1, color = "red", alpha = 0.5), - point.args = list(size = 3, alpha = 0.5, na.rm = TRUE), - point.path = TRUE, - point.path.args = list(alpha = 0.5, linetype = "dashed"), - boxplot.args = list(width = 0.2, alpha = 0.5, na.rm = TRUE), - violin.args = list(width = 0.5, alpha = 0.2, na.rm = TRUE), - ggsignif.args = list(textsize = 3, tip_length = 0.01, na.rm = TRUE), - ggtheme = ggstatsplot::theme_ggstatsplot(), - package = "RColorBrewer", - palette = "Dark2", - ggplot.component = NULL, - ...) { +ggwithinstats <- function( + data, + x, + y, + type = "parametric", + pairwise.display = "significant", + p.adjust.method = "holm", + effsize.type = "unbiased", + bf.prior = 0.707, + bf.message = TRUE, + results.subtitle = TRUE, + xlab = NULL, + ylab = NULL, + caption = NULL, + title = NULL, + subtitle = NULL, + k = 2L, + conf.level = 0.95, + nboot = 100L, + tr = 0.2, + centrality.plotting = TRUE, + centrality.type = type, + centrality.point.args = list(size = 5, color = "darkred"), + centrality.label.args = list(size = 3, nudge_x = 0.4, segment.linetype = 4), + centrality.path = TRUE, + centrality.path.args = list(linewidth = 1, color = "red", alpha = 0.5), + point.args = list(size = 3, alpha = 0.5, na.rm = TRUE), + point.path = TRUE, + point.path.args = list(alpha = 0.5, linetype = "dashed"), + boxplot.args = list(width = 0.2, alpha = 0.5, na.rm = TRUE), + violin.args = list(width = 0.5, alpha = 0.2, na.rm = TRUE), + ggsignif.args = list(textsize = 3, tip_length = 0.01, na.rm = TRUE), + ggtheme = ggstatsplot::theme_ggstatsplot(), + package = "RColorBrewer", + palette = "Dark2", + ggplot.component = NULL, + ...) { # data ----------------------------------- # ensure the variables work quoted or unquoted @@ -131,8 +132,7 @@ ggwithinstats <- function(data, # statistical analysis ------------------------------------------ - # test to run; depends on the no. of levels of the independent variable - test <- ifelse(nlevels(data %>% pull({{ x }})) < 3L, "t", "anova") + test <- ifelse(nlevels(pull(data, {{ x }})) < 3L, "t", "anova") if (results.subtitle) { .f.args <- list( @@ -164,19 +164,19 @@ ggwithinstats <- function(data, # plot ------------------------------------------- - plot <- ggplot(data, aes({{ x }}, {{ y }}, group = .rowid)) + + plot_comparison <- ggplot(data, aes({{ x }}, {{ y }}, group = .rowid)) + exec(geom_point, aes(color = {{ x }}), !!!point.args) + exec(geom_boxplot, aes({{ x }}, {{ y }}), inherit.aes = FALSE, !!!boxplot.args, outlier.shape = NA) + exec(geom_violin, aes({{ x }}, {{ y }}), inherit.aes = FALSE, !!!violin.args) # add a connecting path only if there are only two groups - if (test == "t" && point.path) plot <- plot + exec(geom_path, !!!point.path.args) + if (test == "t" && point.path) plot_comparison <- plot_comparison + exec(geom_path, !!!point.path.args) # centrality tagging ------------------------------------- if (isTRUE(centrality.plotting)) { - plot <- suppressWarnings(.centrality_ggrepel( - plot = plot, + plot_comparison <- suppressWarnings(.centrality_ggrepel( + plot = plot_comparison, data = data, x = {{ x }}, y = {{ y }}, @@ -208,8 +208,8 @@ ggwithinstats <- function(data, ) # adding the layer for pairwise comparisons - plot <- .ggsignif_adder( - plot = plot, + plot_comparison <- .ggsignif_adder( + plot = plot_comparison, mpc_df = mpc_df, data = data, x = {{ x }}, @@ -225,8 +225,8 @@ ggwithinstats <- function(data, # annotations ------------------------- .aesthetic_addon( - plot = plot, - x = data %>% pull({{ x }}), + plot = plot_comparison, + x = pull(data, {{ x }}), xlab = xlab %||% as_name(x), ylab = ylab %||% as_name(y), title = title, @@ -277,11 +277,12 @@ ggwithinstats <- function(data, #' ggplot.component = scale_y_continuous(breaks = seq(0, 10, 1), limits = c(0, 10)) #' ) #' @export -grouped_ggwithinstats <- function(data, - ..., - grouping.var, - plotgrid.args = list(), - annotation.args = list()) { +grouped_ggwithinstats <- function( + data, + ..., + grouping.var, + plotgrid.args = list(), + annotation.args = list()) { .grouped_list(data, {{ grouping.var }}) %>% purrr::pmap(.f = ggwithinstats, ...) %>% combine_plots(plotgrid.args, annotation.args) diff --git a/R/globals.R b/R/globals.R index 5617b1ce7..a6968ed6f 100644 --- a/R/globals.R +++ b/R/globals.R @@ -16,13 +16,13 @@ utils::globalVariables(c( "conf.high", # ".x", # <.histo_labeller> "var", # <.histo_labeller> - ".counts", # - "perc", # - ".label", # "counts", # "perc", # "counts", # <.cat_counter> "counts", # + ".counts", # + "perc", # + ".label", # ".", # ".rowid", # ".", # <.grouped_list> diff --git a/R/reexports.R b/R/reexports.R index 768d43299..156234110 100644 --- a/R/reexports.R +++ b/R/reexports.R @@ -1,5 +1,5 @@ #' @export -#' @importFrom statsExpressions "%>%" +#' @importFrom statsExpressions %>% statsExpressions::`%>%` #' @export diff --git a/R/theme_ggstatsplot.R b/R/theme-ggstatsplot.R similarity index 100% rename from R/theme_ggstatsplot.R rename to R/theme-ggstatsplot.R diff --git a/R/utils.R b/R/utils.R index 88a75e90d..6733102c5 100644 --- a/R/utils.R +++ b/R/utils.R @@ -34,8 +34,8 @@ #' @keywords internal .is_palette_sufficient <- function(package, palette, min_length) { palette_length <- paletteer::palettes_d_names %>% - filter(package == !!package, palette == !!palette) %$% - length[[1L]] + filter(package == !!package, palette == !!palette) %>% + purrr::pluck("length") are_enough_colors_available <- palette_length > min_length @@ -46,7 +46,7 @@ )) } - return(are_enough_colors_available) + are_enough_colors_available } diff --git a/codemeta.json b/codemeta.json index 3c02d23ab..540b41dfe 100644 --- a/codemeta.json +++ b/codemeta.json @@ -14,7 +14,7 @@ "name": "R", "url": "https://r-project.org" }, - "runtimePlatform": "R version 4.3.1 (2023-06-16)", + "runtimePlatform": "R version 4.3.2 (2023-10-31)", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", @@ -111,6 +111,7 @@ "@type": "SoftwareApplication", "identifier": "lme4", "name": "lme4", + "version": ">= 1.1-35.1", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", @@ -171,7 +172,7 @@ "@type": "SoftwareApplication", "identifier": "PMCMRplus", "name": "PMCMRplus", - "version": ">= 1.9.7", + "version": ">= 1.9.9", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", @@ -204,6 +205,18 @@ }, "sameAs": "https://CRAN.R-project.org/package=rmarkdown" }, + { + "@type": "SoftwareApplication", + "identifier": "rstantools", + "name": "rstantools", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=rstantools" + }, { "@type": "SoftwareApplication", "identifier": "survival", @@ -220,7 +233,7 @@ "@type": "SoftwareApplication", "identifier": "testthat", "name": "testthat", - "version": ">= 3.2.0", + "version": ">= 3.2.1", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", @@ -303,7 +316,7 @@ "@type": "SoftwareApplication", "identifier": "datawizard", "name": "datawizard", - "version": ">= 0.9.0", + "version": ">= 0.9.1", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", @@ -316,7 +329,7 @@ "@type": "SoftwareApplication", "identifier": "dplyr", "name": "dplyr", - "version": ">= 1.1.3", + "version": ">= 1.1.4", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", @@ -355,7 +368,7 @@ "@type": "SoftwareApplication", "identifier": "ggrepel", "name": "ggrepel", - "version": ">= 0.9.4", + "version": ">= 0.9.5", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", @@ -368,7 +381,7 @@ "@type": "SoftwareApplication", "identifier": "ggside", "name": "ggside", - "version": ">= 0.2.2", + "version": ">= 0.2.3", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", @@ -406,7 +419,7 @@ "@type": "SoftwareApplication", "identifier": "insight", "name": "insight", - "version": ">= 0.19.6", + "version": ">= 0.19.7", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", @@ -432,7 +445,7 @@ "@type": "SoftwareApplication", "identifier": "parameters", "name": "parameters", - "version": ">= 0.21.2", + "version": ">= 0.21.3", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", @@ -445,7 +458,7 @@ "@type": "SoftwareApplication", "identifier": "patchwork", "name": "patchwork", - "version": ">= 1.1.3", + "version": ">= 1.2.0", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", @@ -501,14 +514,14 @@ "@type": "SoftwareApplication", "identifier": "statsExpressions", "name": "statsExpressions", - "version": ">= 1.5.2.9000", + "version": ">= 1.5.3", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", "name": "Comprehensive R Archive Network (CRAN)", "url": "https://cran.r-project.org" }, - "sameAs": "https://github.com/IndrajeetPatil/statsExpressions" + "sameAs": "https://CRAN.R-project.org/package=statsExpressions" }, "20": { "@type": "SoftwareApplication", @@ -530,7 +543,7 @@ }, "SystemRequirements": null }, - "fileSize": "9371.364KB", + "fileSize": "9364.282KB", "citation": [ { "@type": "ScholarlyArticle", diff --git a/data-raw/Titanic_full.R b/data-raw/Titanic-full.R similarity index 81% rename from data-raw/Titanic_full.R rename to data-raw/Titanic-full.R index 7d244de10..a14002359 100644 --- a/data-raw/Titanic_full.R +++ b/data-raw/Titanic-full.R @@ -5,8 +5,10 @@ Titanic_full <- dplyr::mutate(dplyr::across(dplyr::vars("id"), ~ as.factor(.x))) |> split(f = .$id) |> purrr::map_dfr(tidyr::uncount, n) |> - dplyr::mutate(dplyr::across(dplyr::vars("id"), ~ as.numeric(as.character(.x)))) |> - dplyr::mutate(dplyr::across(where(is.character), ~ droplevels(as.factor(.x)))) |> + dplyr::mutate( + dplyr::across(dplyr::vars("id"), ~ as.numeric(as.character(.x))), + dplyr::across(where(is.character), ~ droplevels(as.factor(.x))) + ) |> dplyr::select(-n, -id) |> tibble::rownames_to_column(var = "id") |> dplyr::mutate(dplyr::across("id", ~ as.numeric(as.character(.x)))) diff --git a/data-raw/bugs_long.R b/data-raw/bugs-long.R similarity index 100% rename from data-raw/bugs_long.R rename to data-raw/bugs-long.R diff --git a/data-raw/bugs_wide.R b/data-raw/bugs-wide.R similarity index 100% rename from data-raw/bugs_wide.R rename to data-raw/bugs-wide.R diff --git a/data-raw/iris_long.R b/data-raw/iris-long.R similarity index 100% rename from data-raw/iris_long.R rename to data-raw/iris-long.R diff --git a/data-raw/movies_wide_long.R b/data-raw/movies-wide-long.R similarity index 82% rename from data-raw/movies_wide_long.R rename to data-raw/movies-wide-long.R index 4ffd40f7f..224972020 100644 --- a/data-raw/movies_wide_long.R +++ b/data-raw/movies-wide-long.R @@ -1,15 +1,17 @@ library(magrittr) # clean data leave it in wide format -movies_wide <- ggplot2movies::movies %>% +movies_wide <- + ggplot2movies::movies %>% dplyr::select(c(title:votes, mpaa:Short)) %>% - dplyr::filter(mpaa != "", mpaa != "NC-17") %>% - dplyr::filter(Short != 1L, Documentary != 1L) %>% + dplyr::filter(mpaa != "", mpaa != "NC-17", Short != 1L, Documentary != 1L) %>% dplyr::select(-c(Short, Documentary)) %>% tidyr::drop_na() %>% - dplyr::mutate(budget = budget / 1000000) %>% - dplyr::mutate(mpaa = factor(mpaa)) %>% - dplyr::mutate(NumGenre = as.integer(rowSums(dplyr::select(., Action:Romance)))) %>% + dplyr::mutate( + budget = budget / 1000000, + mpaa = factor(mpaa), + NumGenre = as.integer(rowSums(dplyr::select(., Action:Romance))) + ) %>% dplyr::filter(NumGenre > 0L) # see the selected data (we have data from 1,579 movies) diff --git a/man/combine_plots.Rd b/man/combine_plots.Rd index b482818dd..62006ac4d 100644 --- a/man/combine_plots.Rd +++ b/man/combine_plots.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/combine_plots.R +% Please edit documentation in R/combine-plots.R \name{combine_plots} \alias{combine_plots} \title{Combining and arranging multiple plots in a grid} diff --git a/man/extract_stats.Rd b/man/extract_stats.Rd index db9e10753..705534cad 100644 --- a/man/extract_stats.Rd +++ b/man/extract_stats.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/extract_stats.R +% Please edit documentation in R/extract-stats.R \name{extract_stats} \alias{extract_stats} \alias{extract_subtitle} diff --git a/man/ggbetweenstats.Rd b/man/ggbetweenstats.Rd index f45655524..816fe46af 100644 --- a/man/ggbetweenstats.Rd +++ b/man/ggbetweenstats.Rd @@ -422,9 +422,11 @@ ggbetweenstats( # you can remove a specific geom to reduce complexity of the plot ggbetweenstats( - mtcars, am, wt, + mtcars, + am, + wt, # to remove violin plot - violin.args = list(width = 0), + violin.args = list(width = 0, linewidth = 0), # to remove boxplot boxplot.args = list(width = 0), # to remove points diff --git a/man/ggstatsplot-package.Rd b/man/ggstatsplot-package.Rd index 6636e33b7..0d3c957b9 100644 --- a/man/ggstatsplot-package.Rd +++ b/man/ggstatsplot-package.Rd @@ -3,7 +3,6 @@ \docType{package} \name{ggstatsplot-package} \alias{ggstatsplot-package} -\alias{_PACKAGE} \alias{ggstatsplot} \title{ggstatsplot: 'ggplot2' Based Plots with Statistical Details} \description{ diff --git a/man/ggwithinstats.Rd b/man/ggwithinstats.Rd index f93300310..507e1238b 100644 --- a/man/ggwithinstats.Rd +++ b/man/ggwithinstats.Rd @@ -439,7 +439,7 @@ ggbetweenstats( x = condition, y = desire, # to remove violin plot - violin.args = list(width = 0), + violin.args = list(width = 0, linewidth = 0), # to remove boxplot boxplot.args = list(width = 0), # to remove points diff --git a/man/theme_ggstatsplot.Rd b/man/theme_ggstatsplot.Rd index 3287bd806..860e08cde 100644 --- a/man/theme_ggstatsplot.Rd +++ b/man/theme_ggstatsplot.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/theme_ggstatsplot.R +% Please edit documentation in R/theme-ggstatsplot.R \name{theme_ggstatsplot} \alias{theme_ggstatsplot} \title{Default theme used in \code{{ggstatsplot}}} diff --git a/tests/testthat/_snaps/combine_plots/defaults-work-as-expected.svg b/tests/testthat/_snaps/combine-plots/defaults-work-as-expected.svg similarity index 100% rename from tests/testthat/_snaps/combine_plots/defaults-work-as-expected.svg rename to tests/testthat/_snaps/combine-plots/defaults-work-as-expected.svg diff --git a/tests/testthat/_snaps/extract_stats.md b/tests/testthat/_snaps/extract-stats.md similarity index 100% rename from tests/testthat/_snaps/extract_stats.md rename to tests/testthat/_snaps/extract-stats.md diff --git a/tests/testthat/_snaps/ggbarstats.md b/tests/testthat/_snaps/ggbarstats.md index 17ab76d2f..11c7d12a4 100644 --- a/tests/testthat/_snaps/ggbarstats.md +++ b/tests/testthat/_snaps/ggbarstats.md @@ -1,4 +1,8 @@ # grouped_ggbarstats produces error when grouping variable not provided - argument 1 is empty + Code + grouped_ggbarstats(mtcars, x = cyl, y = am) + Condition + Error in `list()`: + ! argument 1 is empty diff --git a/tests/testthat/_snaps/ggbetweenstats/specific-geoms-removed.svg b/tests/testthat/_snaps/ggbetweenstats/specific-geoms-removed.svg index 60018334d..cab56487f 100644 --- a/tests/testthat/_snaps/ggbetweenstats/specific-geoms-removed.svg +++ b/tests/testthat/_snaps/ggbetweenstats/specific-geoms-removed.svg @@ -78,8 +78,8 @@ - - + + diff --git a/tests/testthat/_snaps/ggcorrmat.md b/tests/testthat/_snaps/ggcorrmat.md index eac214b31..86d8ef69a 100644 --- a/tests/testthat/_snaps/ggcorrmat.md +++ b/tests/testthat/_snaps/ggcorrmat.md @@ -1,8 +1,8 @@ -# ggcorrmat warnings are as expected - - Mismatch between number of variables and names. - # grouped_ggcorrmat produces error when grouping isn't specified - argument 1 is empty + Code + grouped_ggcorrmat(iris) + Condition + Error in `list()`: + ! argument 1 is empty diff --git a/tests/testthat/_snaps/gghistostats/aesthetic-modifications-work.svg b/tests/testthat/_snaps/gghistostats/aesthetic-modifications-work.svg index c805c27fd..d8bdc3ac4 100644 --- a/tests/testthat/_snaps/gghistostats/aesthetic-modifications-work.svg +++ b/tests/testthat/_snaps/gghistostats/aesthetic-modifications-work.svg @@ -27,66 +27,73 @@ - - - - - - + + + + + + + + + - + + - - - - - - - - - - - - - - - + + + + + + + + + + -μ - -m -e -a -n -= -174.36 - +μ + +m +e +a +n += +3.22 + 0 -10 -20 -30 +5 +10 +15 +20 +25 - + + - + + - - - - + + + 0% -10% -20% -30% -40% - - -100 -200 -character height +20% +40% +60% + + + + + +-2.5 +0.0 +2.5 +5.0 +7.5 +weight count proportion -starwars: character heights +mtcars: car wights diff --git a/tests/testthat/_snaps/gghistostats/robust-with-na.svg b/tests/testthat/_snaps/gghistostats/robust-with-na.svg index f467df525..a5421832b 100644 --- a/tests/testthat/_snaps/gghistostats/robust-with-na.svg +++ b/tests/testthat/_snaps/gghistostats/robust-with-na.svg @@ -27,113 +27,112 @@ - - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + -μ - -t -r -i -m -m -e -d -= -179.33 - +μ + +t +r +i +m +m +e +d += +10.48 + 0 -10 -20 -30 +5 +10 +15 - - - + + + - - - - + + + + 0% -10% -20% -30% -40% - - - - - -50 -100 -150 -200 -250 -height +5% +10% +15% +20% + + + + + +0 +5 +10 +15 +20 +sleep_total count proportion t bootstrapped = -14.38 -, - -p -= -0.00 -, - -μ - -trimmed -= -179.33 -, - -C -I -95% - -[ -175.06 -, - -183.60 -] -, - -n -obs -= -81 +0.85 +, + +p += +0.41 +, + +μ + +trimmed += +10.48 +, + +C +I +95% + +[ +9.33 +, + +11.64 +] +, + +n +obs += +83 diff --git a/tests/testthat/_snaps/pairwise_ggsignif/adding-caption-works.svg b/tests/testthat/_snaps/pairwise-ggsignif/adding-caption-works.svg similarity index 100% rename from tests/testthat/_snaps/pairwise_ggsignif/adding-caption-works.svg rename to tests/testthat/_snaps/pairwise-ggsignif/adding-caption-works.svg diff --git a/tests/testthat/_snaps/pairwise_ggsignif/between-bayes.svg b/tests/testthat/_snaps/pairwise-ggsignif/between-bayes.svg similarity index 100% rename from tests/testthat/_snaps/pairwise_ggsignif/between-bayes.svg rename to tests/testthat/_snaps/pairwise-ggsignif/between-bayes.svg diff --git a/tests/testthat/_snaps/pairwise_ggsignif/between-non-parametric-all.svg b/tests/testthat/_snaps/pairwise-ggsignif/between-non-parametric-all.svg similarity index 100% rename from tests/testthat/_snaps/pairwise_ggsignif/between-non-parametric-all.svg rename to tests/testthat/_snaps/pairwise-ggsignif/between-non-parametric-all.svg diff --git a/tests/testthat/_snaps/pairwise_ggsignif/between-non-parametric-only-non-significant.svg b/tests/testthat/_snaps/pairwise-ggsignif/between-non-parametric-only-non-significant.svg similarity index 100% rename from tests/testthat/_snaps/pairwise_ggsignif/between-non-parametric-only-non-significant.svg rename to tests/testthat/_snaps/pairwise-ggsignif/between-non-parametric-only-non-significant.svg diff --git a/tests/testthat/_snaps/pairwise_ggsignif/between-non-parametric-only-significant.svg b/tests/testthat/_snaps/pairwise-ggsignif/between-non-parametric-only-significant.svg similarity index 100% rename from tests/testthat/_snaps/pairwise_ggsignif/between-non-parametric-only-significant.svg rename to tests/testthat/_snaps/pairwise-ggsignif/between-non-parametric-only-significant.svg diff --git a/tests/testthat/_snaps/pairwise_ggsignif/between-parametric-all.svg b/tests/testthat/_snaps/pairwise-ggsignif/between-parametric-all.svg similarity index 100% rename from tests/testthat/_snaps/pairwise_ggsignif/between-parametric-all.svg rename to tests/testthat/_snaps/pairwise-ggsignif/between-parametric-all.svg diff --git a/tests/testthat/_snaps/pairwise_ggsignif/between-parametric-only-non-significant.svg b/tests/testthat/_snaps/pairwise-ggsignif/between-parametric-only-non-significant.svg similarity index 100% rename from tests/testthat/_snaps/pairwise_ggsignif/between-parametric-only-non-significant.svg rename to tests/testthat/_snaps/pairwise-ggsignif/between-parametric-only-non-significant.svg diff --git a/tests/testthat/_snaps/pairwise_ggsignif/between-parametric-only-significant.svg b/tests/testthat/_snaps/pairwise-ggsignif/between-parametric-only-significant.svg similarity index 100% rename from tests/testthat/_snaps/pairwise_ggsignif/between-parametric-only-significant.svg rename to tests/testthat/_snaps/pairwise-ggsignif/between-parametric-only-significant.svg diff --git a/tests/testthat/_snaps/pairwise_ggsignif/between-robust-all.svg b/tests/testthat/_snaps/pairwise-ggsignif/between-robust-all.svg similarity index 100% rename from tests/testthat/_snaps/pairwise_ggsignif/between-robust-all.svg rename to tests/testthat/_snaps/pairwise-ggsignif/between-robust-all.svg diff --git a/tests/testthat/_snaps/pairwise_ggsignif/between-robust-only-non-significant.svg b/tests/testthat/_snaps/pairwise-ggsignif/between-robust-only-non-significant.svg similarity index 100% rename from tests/testthat/_snaps/pairwise_ggsignif/between-robust-only-non-significant.svg rename to tests/testthat/_snaps/pairwise-ggsignif/between-robust-only-non-significant.svg diff --git a/tests/testthat/_snaps/pairwise_ggsignif/between-robust-only-significant.svg b/tests/testthat/_snaps/pairwise-ggsignif/between-robust-only-significant.svg similarity index 100% rename from tests/testthat/_snaps/pairwise_ggsignif/between-robust-only-significant.svg rename to tests/testthat/_snaps/pairwise-ggsignif/between-robust-only-significant.svg diff --git a/tests/testthat/_snaps/pairwise_ggsignif/within-bayes.svg b/tests/testthat/_snaps/pairwise-ggsignif/within-bayes.svg similarity index 100% rename from tests/testthat/_snaps/pairwise_ggsignif/within-bayes.svg rename to tests/testthat/_snaps/pairwise-ggsignif/within-bayes.svg diff --git a/tests/testthat/_snaps/pairwise_ggsignif/within-non-parametric-all.svg b/tests/testthat/_snaps/pairwise-ggsignif/within-non-parametric-all.svg similarity index 100% rename from tests/testthat/_snaps/pairwise_ggsignif/within-non-parametric-all.svg rename to tests/testthat/_snaps/pairwise-ggsignif/within-non-parametric-all.svg diff --git a/tests/testthat/_snaps/pairwise_ggsignif/within-non-parametric-only-non-significant.svg b/tests/testthat/_snaps/pairwise-ggsignif/within-non-parametric-only-non-significant.svg similarity index 100% rename from tests/testthat/_snaps/pairwise_ggsignif/within-non-parametric-only-non-significant.svg rename to tests/testthat/_snaps/pairwise-ggsignif/within-non-parametric-only-non-significant.svg diff --git a/tests/testthat/_snaps/pairwise_ggsignif/within-non-parametric-only-significant.svg b/tests/testthat/_snaps/pairwise-ggsignif/within-non-parametric-only-significant.svg similarity index 100% rename from tests/testthat/_snaps/pairwise_ggsignif/within-non-parametric-only-significant.svg rename to tests/testthat/_snaps/pairwise-ggsignif/within-non-parametric-only-significant.svg diff --git a/tests/testthat/_snaps/pairwise_ggsignif/within-parametric-all.svg b/tests/testthat/_snaps/pairwise-ggsignif/within-parametric-all.svg similarity index 100% rename from tests/testthat/_snaps/pairwise_ggsignif/within-parametric-all.svg rename to tests/testthat/_snaps/pairwise-ggsignif/within-parametric-all.svg diff --git a/tests/testthat/_snaps/pairwise_ggsignif/within-parametric-only-non-significant.svg b/tests/testthat/_snaps/pairwise-ggsignif/within-parametric-only-non-significant.svg similarity index 100% rename from tests/testthat/_snaps/pairwise_ggsignif/within-parametric-only-non-significant.svg rename to tests/testthat/_snaps/pairwise-ggsignif/within-parametric-only-non-significant.svg diff --git a/tests/testthat/_snaps/pairwise_ggsignif/within-parametric-only-significant.svg b/tests/testthat/_snaps/pairwise-ggsignif/within-parametric-only-significant.svg similarity index 100% rename from tests/testthat/_snaps/pairwise_ggsignif/within-parametric-only-significant.svg rename to tests/testthat/_snaps/pairwise-ggsignif/within-parametric-only-significant.svg diff --git a/tests/testthat/_snaps/pairwise_ggsignif/within-robust-all.svg b/tests/testthat/_snaps/pairwise-ggsignif/within-robust-all.svg similarity index 100% rename from tests/testthat/_snaps/pairwise_ggsignif/within-robust-all.svg rename to tests/testthat/_snaps/pairwise-ggsignif/within-robust-all.svg diff --git a/tests/testthat/_snaps/pairwise_ggsignif/within-robust-only-non-significant.svg b/tests/testthat/_snaps/pairwise-ggsignif/within-robust-only-non-significant.svg similarity index 100% rename from tests/testthat/_snaps/pairwise_ggsignif/within-robust-only-non-significant.svg rename to tests/testthat/_snaps/pairwise-ggsignif/within-robust-only-non-significant.svg diff --git a/tests/testthat/_snaps/pairwise_ggsignif/within-robust-only-significant.svg b/tests/testthat/_snaps/pairwise-ggsignif/within-robust-only-significant.svg similarity index 100% rename from tests/testthat/_snaps/pairwise_ggsignif/within-robust-only-significant.svg rename to tests/testthat/_snaps/pairwise-ggsignif/within-robust-only-significant.svg diff --git a/tests/testthat/test-combine_plots.R b/tests/testthat/test-combine-plots.R similarity index 93% rename from tests/testthat/test-combine_plots.R rename to tests/testthat/test-combine-plots.R index 35de8165d..c52e7f3e6 100644 --- a/tests/testthat/test-combine_plots.R +++ b/tests/testthat/test-combine-plots.R @@ -1,6 +1,6 @@ test_that( - desc = "checking if combining plots works", - code = { + "checking if combining plots works", + { p1 <- ggplot2::ggplot( data = subset(iris, iris$Species == "setosa"), aes(x = Sepal.Length, y = Sepal.Width) diff --git a/tests/testthat/test-extract_stats.R b/tests/testthat/test-extract-stats.R similarity index 96% rename from tests/testthat/test-extract_stats.R rename to tests/testthat/test-extract-stats.R index 48c41b5ae..25cfec5a1 100644 --- a/tests/testthat/test-extract_stats.R +++ b/tests/testthat/test-extract-stats.R @@ -1,6 +1,6 @@ test_that( - desc = "checking if extract_stats works", - code = { + "checking if extract_stats works", + { skip_if_not_installed("PMCMRplus") skip_if_not_installed("rstantools") options(tibble.width = Inf) diff --git a/tests/testthat/test-ggbarstats.R b/tests/testthat/test-ggbarstats.R index 22f6c1344..baaae9eec 100644 --- a/tests/testthat/test-ggbarstats.R +++ b/tests/testthat/test-ggbarstats.R @@ -16,8 +16,8 @@ survey_data_NA <- dplyr::tibble( # checking default outputs ----------------------------------------- test_that( - desc = "checking default outputs", - code = { + "checking default outputs", + { set.seed(123) expect_doppelganger( title = "checking unpaired two-way table - without NA", @@ -33,7 +33,10 @@ test_that( set.seed(123) expect_doppelganger( title = "checking paired two-way table - without NA", - fig = ggbarstats(survey_data, `1st survey`, `2nd survey`, + fig = ggbarstats( + survey_data, + `1st survey`, + `2nd survey`, counts = Counts, paired = TRUE ) @@ -56,13 +59,16 @@ test_that( # changing labels and aesthetics ------------------------------------------- test_that( - desc = "changing labels and aesthetics", - code = { + "changing labels and aesthetics", + { set.seed(123) expect_doppelganger( title = "checking percentage labels", fig = ggbarstats( - data = mtcars, x = cyl, y = am, label = "percentage", + data = mtcars, + x = cyl, + y = am, + label = "percentage", results.subtitle = FALSE ) ) @@ -71,7 +77,10 @@ test_that( expect_doppelganger( title = "checking count labels", fig = ggbarstats( - data = mtcars, x = cyl, y = am, label = "counts", + data = mtcars, + x = cyl, + y = am, + label = "counts", results.subtitle = FALSE ) ) @@ -80,7 +89,10 @@ test_that( expect_doppelganger( title = "checking percentage and count labels", fig = ggbarstats( - data = mtcars, x = cyl, y = am, label = "both", + data = mtcars, + x = cyl, + y = am, + label = "both", results.subtitle = FALSE ) ) @@ -113,8 +125,10 @@ test_that( .Label = c("Before", "After"), class = "factor" ), - mode = structure(c(1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L), - .Label = c("A", "P", "C", "T"), class = "factor" + mode = structure( + c(1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L), + .Label = c("A", "P", "C", "T"), + class = "factor" ), counts = c(30916L, 21117L, 7676L, 1962L, 1663L, 462L, 7221L, 197L), perc = c(65.119, 88.958, 16.168, 8.265, 3.502, 1.946, 15.209, 0.829), @@ -142,8 +156,8 @@ test_that( # edge cases --------------------------------------------------------- test_that( - desc = "edge cases", - code = { + "edge cases", + { # dropped level dataset mtcars_small <- dplyr::filter(mtcars, am == "0") @@ -165,8 +179,8 @@ test_that( # expression output -------------------------------------------------- test_that( - desc = "expression output", - code = { + "expression output", + { set.seed(123) p_sub <- ggbarstats( data = ggplot2::msleep, @@ -189,15 +203,15 @@ test_that( ) test_that( - desc = "grouped_ggbarstats produces error when grouping variable not provided", - code = { - expect_snapshot_error(grouped_ggbarstats(mtcars, x = cyl, y = am)) + "grouped_ggbarstats produces error when grouping variable not provided", + { + expect_snapshot(grouped_ggbarstats(mtcars, x = cyl, y = am), error = TRUE) } ) test_that( - desc = "grouped_ggbarstats works", - code = { + "grouped_ggbarstats works", + { # creating a smaller data frame mpg_short <- ggplot2::mpg %>% dplyr::filter( @@ -224,8 +238,8 @@ test_that( # edge cases -------------------- test_that( - desc = "edge case behavior", - code = { + "edge case behavior", + { df <- data.frame( dataset = c("a", "b", "c", "c", "c", "c"), measurement = c("old", "old", "old", "old", "new", "new"), diff --git a/tests/testthat/test-ggbetweenstats.R b/tests/testthat/test-ggbetweenstats.R index 5a8d4e28d..9c276b7d0 100644 --- a/tests/testthat/test-ggbetweenstats.R +++ b/tests/testthat/test-ggbetweenstats.R @@ -5,8 +5,8 @@ skip_if_not_installed("rstantools") # checking labels and data from plot ------------------------------------- test_that( - desc = "plotting features work as expected", - code = { + "plotting features work as expected", + { set.seed(123) expect_doppelganger( title = "modification with ggplot2 works as expected", @@ -47,7 +47,7 @@ test_that( y = wt, xlab = "Transmission", ylab = "Weight", - violin.args = list(width = 0), + violin.args = list(width = 0, linewidth = 0), boxplot.args = list(width = 0), point.args = list(alpha = 0), title = "Bayesian Test" @@ -59,8 +59,8 @@ test_that( # subtitle output works ------------------------------------------------ test_that( - desc = "subtitle output works", - code = { + "subtitle output works", + { skip_on_cran() df <- mtcars @@ -89,8 +89,8 @@ test_that( # grouped_ggbetweenstats defaults -------------------------------------------------- test_that( - desc = "grouped_ggbetweenstats defaults", - code = { + "grouped_ggbetweenstats defaults", + { # expect error when no grouping.var is specified expect_snapshot_error(grouped_ggbetweenstats(mtcars, x = am, y = wt)) diff --git a/tests/testthat/test-ggcoefstats.R b/tests/testthat/test-ggcoefstats.R index bebd572ba..12d27ee56 100644 --- a/tests/testthat/test-ggcoefstats.R +++ b/tests/testthat/test-ggcoefstats.R @@ -84,8 +84,8 @@ test_that("meta-analysis works", { # plot modifications-------------------------------------------------- test_that( - desc = "plot modifications work as expected", - code = { + "plot modifications work as expected", + { set.seed(123) mod1 <- stats::lm(data = mtcars, formula = wt ~ mpg * am) @@ -131,8 +131,8 @@ test_that( # edge cases ------------------------------------- test_that( - desc = "works when CIs unavailable", - code = { + "works when CIs unavailable", + { set.seed(123) df_base <- tidy_model_parameters(stats::lm(wt ~ am * cyl, mtcars)) @@ -154,8 +154,8 @@ test_that( # meta subtitle and caption ------------------------------------- test_that( - desc = "meta analysis subtitle and caption", - code = { + "meta analysis subtitle and caption", + { skip_on_cran() skip_if_not_installed("metafor") skip_if_not_installed("metaBMA") @@ -168,22 +168,20 @@ test_that( caption_expr <- suppressWarnings(meta_analysis(df_meta, type = "bayes")) set.seed(123) - ggcoef_subtitle <- suppressWarnings(ggcoefstats( + ggcoef_subtitle <- extract_subtitle(suppressWarnings(ggcoefstats( df_meta, meta.analytic.effect = TRUE, bf.message = FALSE, meta.type = "p" - ) %>% - extract_subtitle()) + ))) set.seed(123) - ggcoef_caption <- suppressWarnings(ggcoefstats( + ggcoef_caption <- extract_caption(suppressWarnings(ggcoefstats( df_meta, meta.analytic.effect = TRUE, bf.message = TRUE, meta.type = "p" - ) %>% - extract_caption()) + ))) expect_identical(subtitle_expr$expression[[1L]], ggcoef_subtitle) expect_identical(caption_expr$expression[[1L]], ggcoef_caption) diff --git a/tests/testthat/test-ggcorrmat.R b/tests/testthat/test-ggcorrmat.R index 098ea229f..2009c1fcb 100644 --- a/tests/testthat/test-ggcorrmat.R +++ b/tests/testthat/test-ggcorrmat.R @@ -1,6 +1,6 @@ test_that( - desc = "checking ggcorrmat with entier dataset", - code = { + "checking ggcorrmat with entier dataset", + { set.seed(123) expect_doppelganger( title = "parametric correlation - without NAs", @@ -15,20 +15,11 @@ test_that( } ) -# expected warnings ------------------------------------------- - -test_that( - desc = "ggcorrmat warnings are as expected", - code = { - expect_snapshot_warning(ggcorrmat(iris, cor.vars.names = "x")) - } -) - # changing defaults ------------------------------------------- test_that( - desc = "ggcorrmat works as expected with changed defaults", - code = { + "ggcorrmat works as expected with changed defaults", + { set.seed(123) expect_doppelganger( title = "changing aesthetic defaults", @@ -70,8 +61,8 @@ test_that( # grouped_ggcorrmat output: plot --------------------------------------------------------------- test_that( - desc = "grouped_ggcorrmat plots are as expected", - code = { + "grouped_ggcorrmat plots are as expected", + { set.seed(123) expect_doppelganger( title = "without NAs", @@ -96,8 +87,8 @@ test_that( # expected warnings ------------------------------------------- test_that( - desc = "grouped_ggcorrmat produces error when grouping isn't specified", - code = { - expect_snapshot_error(grouped_ggcorrmat(iris)) + "grouped_ggcorrmat produces error when grouping isn't specified", + { + expect_snapshot(grouped_ggcorrmat(iris), error = TRUE) } ) diff --git a/tests/testthat/test-ggdotplotstats.R b/tests/testthat/test-ggdotplotstats.R index 9b7b4ad09..261034cdb 100644 --- a/tests/testthat/test-ggdotplotstats.R +++ b/tests/testthat/test-ggdotplotstats.R @@ -1,4 +1,3 @@ -# creating a new dataset morley_new <- dplyr::mutate( morley, Expt = dplyr::case_when( @@ -18,8 +17,8 @@ morley_new[87L, 3L] <- NA_integer_ # checking default outputs ----------------------------------------- test_that( - desc = "checking default outputs", - code = { + "checking default outputs", + { set.seed(123) expect_doppelganger( title = "parametric - without NA", @@ -38,8 +37,8 @@ test_that( # modification with ggplot2 ---------------------------------------------- test_that( - desc = "modification with ggplot2 works as expected", - code = { + "modification with ggplot2 works as expected", + { set.seed(123) expect_doppelganger( title = "modification with ggplot2 ", @@ -63,27 +62,29 @@ test_that( # subtitle output ------------------------------------------------------- test_that( - desc = "subtitle output", - code = { + "subtitle output", + { set.seed(123) - p_sub_ggdot <- suppressWarnings(ggdotplotstats( + p_sub_ggdot <- ggdotplotstats( data = morley, x = Speed, y = Expt, test.value = 800, type = "np" ) %>% - extract_subtitle()) + extract_subtitle() set.seed(123) - p_sub_gghist <- suppressWarnings(gghistostats( - data = dplyr::group_by(morley, Expt) %>% - dplyr::summarise(mean = mean(Speed)), - x = mean, - test.value = 800, - type = "np" - ) %>% - extract_subtitle()) + p_sub_gghist <- + morley %>% + dplyr::group_by(Expt) %>% + dplyr::summarise(mean = mean(Speed), .groups = "drop") %>% + gghistostats( + x = mean, + test.value = 800, + type = "np" + ) %>% + extract_subtitle() set.seed(123) expect_identical(p_sub_ggdot, p_sub_gghist) @@ -93,8 +94,8 @@ test_that( # grouped_ggdotplotstats works ----------------------------------------------- test_that( - desc = "grouped_ggdotplotstats works", - code = { + "grouped_ggdotplotstats works", + { # removing factor level with very few no. of observations df <- dplyr::filter(ggplot2::mpg, cyl %in% c("4", "6", "8")) diff --git a/tests/testthat/test-gghistostats.R b/tests/testthat/test-gghistostats.R index c02ae14ff..21c87e9b7 100644 --- a/tests/testthat/test-gghistostats.R +++ b/tests/testthat/test-gghistostats.R @@ -1,8 +1,8 @@ # checking default outputs ----------------------------------------- test_that( - desc = "checking default outputs", - code = { + "checking default outputs", + { set.seed(123) expect_doppelganger( title = "parametric - without NA", @@ -12,7 +12,7 @@ test_that( set.seed(123) expect_doppelganger( title = "robust - with NA", - fig = gghistostats(dplyr::starwars, height, test.value = 150, type = "r") + fig = gghistostats(ggplot2::msleep, sleep_total, test.value = 10, type = "r") ) } ) @@ -20,17 +20,17 @@ test_that( # aesthetic modifications work -------------------------------------- test_that( - desc = "aesthetic modifications work", - code = { + "aesthetic modifications work", + { set.seed(123) expect_doppelganger( title = "aesthetic modifications work", fig = gghistostats( - data = dplyr::starwars, - x = height, - xlab = "character height", - title = "starwars: character heights", - binwidth = 20, + data = mtcars, + x = wt, + xlab = "weight", + title = "mtcars: car wights", + binwidth = 5, bin.args = list( col = "black", fill = "orange", @@ -45,8 +45,8 @@ test_that( # normal curve works ------------------------------------- test_that( - desc = "checking if normal curve work", - code = { + "checking if normal curve work", + { set.seed(123) expect_doppelganger( title = "plot normal curve", @@ -65,8 +65,8 @@ test_that( # subtitle output -------------------------------------------------- test_that( - desc = "subtitle output", - code = { + "subtitle output", + { set.seed(123) p_sub <- gghistostats( data = ggplot2::msleep, @@ -91,8 +91,8 @@ test_that( # utilities --------------- test_that( - desc = ".binwidth works as expected", - code = { + ".binwidth works as expected", + { expect_equal(ggstatsplot:::.binwidth(mtcars$wt), 0.6913737, tolerance = 0.001) } ) @@ -100,8 +100,8 @@ test_that( # grouped_gghistostats works --------------------------------------------- test_that( - desc = "grouped_gghistostats plotting works as expected", - code = { + "grouped_gghistostats plotting works as expected", + { set.seed(123) expect_doppelganger( title = "defaults as expected", diff --git a/tests/testthat/test-ggpiestats.R b/tests/testthat/test-ggpiestats.R index 7dbf44f12..021a03b53 100644 --- a/tests/testthat/test-ggpiestats.R +++ b/tests/testthat/test-ggpiestats.R @@ -15,8 +15,8 @@ survey_data_NA <- dplyr::tibble( # checking default outputs ----------------------------------------- test_that( - desc = "checking default outputs", - code = { + "checking default outputs", + { set.seed(123) expect_doppelganger( title = "checking one-way table - without NA", @@ -44,7 +44,10 @@ test_that( set.seed(123) expect_doppelganger( title = "checking paired two-way table - without NA", - fig = ggpiestats(survey_data, `1st survey`, `2nd survey`, + fig = ggpiestats( + survey_data, + `1st survey`, + `2nd survey`, counts = Counts, paired = TRUE ) @@ -67,14 +70,15 @@ test_that( # changing labels and aesthetics ------------------------------------------- test_that( - desc = "changing labels and aesthetics", - code = { + "changing labels and aesthetics", + { set.seed(123) expect_doppelganger( title = "checking percentage labels", fig = ggpiestats( mtcars, - x = cyl, label = "percentage", + x = cyl, + label = "percentage", results.subtitle = FALSE ) ) @@ -84,7 +88,8 @@ test_that( title = "checking count labels", fig = ggpiestats( mtcars, - x = cyl, label = "counts", + x = cyl, + label = "counts", results.subtitle = FALSE ) ) @@ -94,7 +99,8 @@ test_that( title = "checking percentage and count labels", fig = ggpiestats( mtcars, - x = cyl, label = "both", + x = cyl, + label = "both", results.subtitle = FALSE ) ) @@ -123,7 +129,9 @@ test_that( expect_doppelganger( title = "label repelling works", fig = ggpiestats( - mtcars, am, vs, + mtcars, + am, + vs, label.repel = TRUE, results.subtitle = FALSE ) @@ -134,8 +142,8 @@ test_that( # edge cases --------------------------------------------------------- test_that( - desc = "edge cases", - code = { + "edge cases", + { # dropped level dataset mtcars_small <- dplyr::filter(mtcars, am == "0") @@ -157,8 +165,8 @@ test_that( # expression output -------------------------------------------------- test_that( - desc = "expression output", - code = { + "expression output", + { set.seed(123) p_sub <- ggpiestats( ggplot2::msleep, @@ -183,15 +191,15 @@ test_that( # grouped_ggpiestats works as expected --------------------- test_that( - desc = "grouped_ggpiestats produces error when grouping variable not provided", - code = { + "grouped_ggpiestats produces error when grouping variable not provided", + { expect_snapshot_error(grouped_ggpiestats(mtcars, x = cyl)) } ) test_that( - desc = "grouped_ggpiestats works", - code = { + "grouped_ggpiestats works", + { set.seed(123) expect_doppelganger( title = "grouped_ggpiestats with one-way table", @@ -228,8 +236,8 @@ test_that( # grouped_ggpiestats edge cases -------------------- test_that( - desc = "edge case behavior", - code = { + "edge case behavior", + { df <- data.frame( dataset = c("a", "b", "c", "c", "c", "c"), measurement = c("old", "old", "old", "old", "new", "new"), diff --git a/tests/testthat/test-ggscatterstats.R b/tests/testthat/test-ggscatterstats.R index c5eff4f6d..f0ee9624d 100644 --- a/tests/testthat/test-ggscatterstats.R +++ b/tests/testthat/test-ggscatterstats.R @@ -1,8 +1,8 @@ # entire dataset ------------------------------------------------ test_that( - desc = "checking ggscatterstats with entire dataset", - code = { + "checking ggscatterstats with entire dataset", + { set.seed(123) expect_doppelganger( title = "parametric correlation - without NAs", @@ -20,12 +20,15 @@ test_that( # aesthetic modifications work --------------------------------------------- test_that( - desc = "aesthetic modifications work", - code = { + "aesthetic modifications work", + { set.seed(123) expect_doppelganger( title = "changing scales and aesthetics", - fig = ggscatterstats(mtcars, wt, mpg, + fig = ggscatterstats( + mtcars, + wt, + mpg, results.subtitle = FALSE, xsidehistogram.args = list( fill = "red", @@ -91,13 +94,13 @@ test_that("labeling variables and expressions work as expected", { # subtitle output ---------------------------------------------------------- test_that( - desc = "subtitle output - ggscatterstats", - code = { + "subtitle output - ggscatterstats", + { set.seed(123) p_sub <- ggscatterstats( - data = dplyr::starwars, - x = mass, - y = height, + data = ggplot2::msleep, + x = sleep_total, + y = bodywt, conf.level = 0.90, type = "r" ) %>% @@ -105,9 +108,9 @@ test_that( set.seed(123) fun_sub <- corr_test( - data = dplyr::starwars, - x = mass, - y = height, + data = ggplot2::msleep, + x = sleep_total, + y = bodywt, conf.level = 0.90, type = "r" )$expression[[1L]] @@ -117,8 +120,8 @@ test_that( ) test_that( - desc = "grouped_ggscatterstats plotting works as expected", - code = { + "grouped_ggscatterstats plotting works as expected", + { set.seed(123) expect_doppelganger( title = "defaults work as expected", @@ -148,8 +151,8 @@ test_that( ) test_that( - desc = "grouped_ggscatterstats errors when no grouping is present", - code = { + "grouped_ggscatterstats errors when no grouping is present", + { expect_snapshot_error( grouped_ggscatterstats( data = iris, diff --git a/tests/testthat/test-ggwithinstats.R b/tests/testthat/test-ggwithinstats.R index 9490568a7..3a8903f5f 100644 --- a/tests/testthat/test-ggwithinstats.R +++ b/tests/testthat/test-ggwithinstats.R @@ -7,8 +7,8 @@ skip_if_not_installed("rstantools") data_bugs_2 <- dplyr::filter(bugs_long, subject <= 30L, condition %in% c("HDLF", "HDHF")) test_that( - desc = "defaults plots", - code = { + "defaults plots", + { expect_snapshot_error(grouped_ggbetweenstats(bugs_long, x = condition, y = desire)) set.seed(123) @@ -44,8 +44,8 @@ test_that( # aesthetic modifications work ------------------------------------------ test_that( - desc = "aesthetic modifications work", - code = { + "aesthetic modifications work", + { set.seed(123) expect_doppelganger( title = "ggplot2 commands work", @@ -76,8 +76,8 @@ test_that( ) test_that( - desc = "grouped plots work", - code = { + "grouped plots work", + { expect_snapshot_error(grouped_ggbetweenstats(bugs_long, x = condition, y = desire)) set.seed(123) diff --git a/tests/testthat/test-pairwise_ggsignif.R b/tests/testthat/test-pairwise-ggsignif.R similarity index 74% rename from tests/testthat/test-pairwise_ggsignif.R rename to tests/testthat/test-pairwise-ggsignif.R index 07db227a1..17940035c 100644 --- a/tests/testthat/test-pairwise_ggsignif.R +++ b/tests/testthat/test-pairwise-ggsignif.R @@ -3,12 +3,15 @@ skip_if_not_installed("PMCMRplus") # between-subjects ------------------------------------------------- test_that( - desc = "check pairwise displays - between-subjects", - code = { + "check pairwise displays - between-subjects", + { set.seed(123) expect_doppelganger( title = "between - parametric - only non-significant", - fig = ggbetweenstats(ggplot2::msleep, vore, brainwt, + fig = ggbetweenstats( + ggplot2::msleep, + vore, + brainwt, type = "p", results.subtitle = FALSE, p.adjust.method = "fdr", @@ -20,7 +23,10 @@ test_that( set.seed(123) expect_doppelganger( title = "between - parametric - only significant", - fig = ggbetweenstats(ggplot2::msleep, vore, brainwt, + fig = ggbetweenstats( + ggplot2::msleep, + vore, + brainwt, type = "p", results.subtitle = FALSE, p.adjust.method = "fdr", @@ -32,7 +38,10 @@ test_that( set.seed(123) expect_doppelganger( title = "between - parametric - all", - fig = ggbetweenstats(ggplot2::msleep, vore, brainwt, + fig = ggbetweenstats( + ggplot2::msleep, + vore, + brainwt, type = "p", results.subtitle = FALSE, p.adjust.method = "fdr", @@ -44,7 +53,10 @@ test_that( set.seed(123) expect_doppelganger( title = "between - non-parametric - only non-significant", - fig = ggbetweenstats(movies_long, mpaa, rating, + fig = ggbetweenstats( + movies_long, + mpaa, + rating, type = "np", results.subtitle = FALSE, p.adjust.method = "bonferroni", @@ -56,7 +68,10 @@ test_that( set.seed(123) expect_doppelganger( title = "between - non-parametric - only significant", - fig = ggbetweenstats(movies_long, mpaa, rating, + fig = ggbetweenstats( + movies_long, + mpaa, + rating, type = "np", results.subtitle = FALSE, p.adjust.method = "bonferroni", @@ -68,7 +83,10 @@ test_that( set.seed(123) expect_doppelganger( title = "between - non-parametric - all", - fig = ggbetweenstats(movies_long, mpaa, rating, + fig = ggbetweenstats( + movies_long, + mpaa, + rating, type = "np", results.subtitle = FALSE, p.adjust.method = "bonferroni", @@ -80,7 +98,10 @@ test_that( set.seed(123) expect_doppelganger( title = "between - robust - only non-significant", - fig = ggbetweenstats(ggplot2::msleep, vore, sleep_rem, + fig = ggbetweenstats( + ggplot2::msleep, + vore, + sleep_rem, type = "r", results.subtitle = FALSE, p.adjust.method = "holm", @@ -92,7 +113,10 @@ test_that( set.seed(123) expect_doppelganger( title = "between - robust - only significant", - fig = ggbetweenstats(ggplot2::msleep, vore, sleep_rem, + fig = ggbetweenstats( + ggplot2::msleep, + vore, + sleep_rem, type = "r", results.subtitle = FALSE, p.adjust.method = "holm", @@ -104,7 +128,10 @@ test_that( set.seed(123) expect_doppelganger( title = "between - robust - all", - fig = ggbetweenstats(ggplot2::msleep, vore, sleep_rem, + fig = ggbetweenstats( + ggplot2::msleep, + vore, + sleep_rem, type = "r", results.subtitle = FALSE, p.adjust.method = "holm", @@ -116,7 +143,10 @@ test_that( set.seed(123) expect_doppelganger( title = "between - bayes", - fig = ggbetweenstats(mtcars, cyl, mpg, + fig = ggbetweenstats( + mtcars, + cyl, + mpg, type = "bayes", results.subtitle = FALSE, k = 3L @@ -128,12 +158,15 @@ test_that( # within-subjects ------------------------------------------------- test_that( - desc = "check pairwise displays - within-subjects", - code = { + "check pairwise displays - within-subjects", + { set.seed(123) expect_doppelganger( title = "within - parametric - only non-significant", - fig = ggwithinstats(bugs_long, condition, desire, + fig = ggwithinstats( + bugs_long, + condition, + desire, type = "p", results.subtitle = FALSE, p.adjust.method = "fdr", @@ -145,7 +178,10 @@ test_that( set.seed(123) expect_doppelganger( title = "within - parametric - only significant", - fig = ggwithinstats(bugs_long, condition, desire, + fig = ggwithinstats( + bugs_long, + condition, + desire, type = "p", results.subtitle = FALSE, p.adjust.method = "fdr", @@ -157,7 +193,10 @@ test_that( set.seed(123) expect_doppelganger( title = "within - parametric - all", - fig = ggwithinstats(bugs_long, condition, desire, + fig = ggwithinstats( + bugs_long, + condition, + desire, type = "p", results.subtitle = FALSE, p.adjust.method = "fdr", @@ -169,7 +208,10 @@ test_that( set.seed(123) expect_doppelganger( title = "within - non-parametric - only non-significant", - fig = ggwithinstats(bugs_long, condition, desire, + fig = ggwithinstats( + bugs_long, + condition, + desire, type = "np", results.subtitle = FALSE, p.adjust.method = "bonferroni", @@ -181,7 +223,10 @@ test_that( set.seed(123) expect_doppelganger( title = "within - non-parametric - only significant", - fig = ggwithinstats(bugs_long, condition, desire, + fig = ggwithinstats( + bugs_long, + condition, + desire, type = "np", results.subtitle = FALSE, p.adjust.method = "bonferroni", @@ -193,7 +238,10 @@ test_that( set.seed(123) expect_doppelganger( title = "within - non-parametric - all", - fig = ggwithinstats(bugs_long, condition, desire, + fig = ggwithinstats( + bugs_long, + condition, + desire, type = "np", results.subtitle = FALSE, p.adjust.method = "bonferroni", @@ -205,7 +253,10 @@ test_that( set.seed(123) expect_doppelganger( title = "within - robust - only non-significant", - fig = ggwithinstats(bugs_long, condition, desire, + fig = ggwithinstats( + bugs_long, + condition, + desire, type = "r", results.subtitle = FALSE, p.adjust.method = "holm", @@ -217,7 +268,10 @@ test_that( set.seed(123) expect_doppelganger( title = "within - robust - only significant", - fig = ggwithinstats(bugs_long, condition, desire, + fig = ggwithinstats( + bugs_long, + condition, + desire, type = "r", results.subtitle = FALSE, p.adjust.method = "holm", @@ -229,7 +283,10 @@ test_that( set.seed(123) expect_doppelganger( title = "within - robust - all", - fig = ggwithinstats(bugs_long, condition, desire, + fig = ggwithinstats( + bugs_long, + condition, + desire, type = "r", results.subtitle = FALSE, p.adjust.method = "holm", @@ -241,7 +298,10 @@ test_that( set.seed(123) expect_doppelganger( title = "within - bayes", - fig = ggwithinstats(bugs_long, condition, desire, + fig = ggwithinstats( + bugs_long, + condition, + desire, type = "bayes", results.subtitle = FALSE, k = 3L @@ -254,12 +314,15 @@ test_that( # caption ------------------------------------------------- test_that( - desc = "adding caption works", - code = { + "adding caption works", + { set.seed(123) expect_doppelganger( title = "adding caption works", - fig = ggwithinstats(bugs_long, condition, desire, + fig = ggwithinstats( + bugs_long, + condition, + desire, type = "p", results.subtitle = FALSE, bf.message = FALSE, diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 6bcd30a1b..418fde47d 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -1,8 +1,8 @@ # .grouped_list ----------------------------------------------------- test_that( - desc = ".grouped_list works with non-syntactic group names", - code = { + ".grouped_list works with non-syntactic group names", + { set.seed(123) expect_snapshot({ sleep %>% @@ -16,8 +16,8 @@ test_that( # .is_palette_sufficient ------------------------------------ test_that( - desc = ".is_palette_sufficient is working", - code = { + ".is_palette_sufficient is working", + { expect_no_condition(.is_palette_sufficient("RColorBrewer", "Dark2", 2L)) expect_snapshot(.is_palette_sufficient("RColorBrewer", "Dark2", 20L)) } @@ -26,8 +26,8 @@ test_that( # .eval_f ------------------------------------ test_that( - desc = ".eval_f works as expected", - code = { + ".eval_f works as expected", + { f <- function() stop("Not working", call. = FALSE) expect_null(.eval_f(f)) }