diff --git a/.github/workflows/R-CMD-check-hard.yaml b/.github/workflows/R-CMD-check-hard.yaml index b6e533f48..cacb5f2dd 100644 --- a/.github/workflows/R-CMD-check-hard.yaml +++ b/.github/workflows/R-CMD-check-hard.yaml @@ -29,7 +29,7 @@ jobs: # https://github.com/jgm/pandoc/releases - uses: r-lib/actions/setup-pandoc@v2 with: - pandoc-version: "3.1.2" + pandoc-version: "3.1.6" - 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 fd3e5ae8c..3c69aa9d5 100644 --- a/.github/workflows/R-CMD-check-strict.yaml +++ b/.github/workflows/R-CMD-check-strict.yaml @@ -38,7 +38,7 @@ jobs: - uses: r-lib/actions/setup-pandoc@v2 with: - pandoc-version: "3.1.2" + pandoc-version: "3.1.6" - 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 9107dcb81..ef2ae6c9f 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -42,7 +42,7 @@ jobs: - uses: r-lib/actions/setup-pandoc@v2 with: - pandoc-version: "3.1.2" + pandoc-version: "3.1.6" - 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 ec550aafa..7c24056b3 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.2" + pandoc-version: "3.1.6" - 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 fede8548d..06075cd35 100644 --- a/.github/workflows/check-random-test-order.yaml +++ b/.github/workflows/check-random-test-order.yaml @@ -18,7 +18,7 @@ jobs: - uses: r-lib/actions/setup-r@v2 with: - r-version: "devel" + r-version: "release" use-public-rspm: true - uses: r-lib/actions/setup-r-dependencies@v2 @@ -34,7 +34,7 @@ jobs: library(cli) library(glue) library(testthat) - pkgload::load_all(".") + pkgload::load_all(".", quiet = TRUE) test_script_paths <- testthat::find_test_scripts("tests/testthat") seed <- sample.int(1e6, 1L) cli_inform("Chosen seed for the current test run: {seed}") diff --git a/.github/workflows/check-readme.yaml b/.github/workflows/check-readme.yaml index 27e65f80f..15104eb27 100644 --- a/.github/workflows/check-readme.yaml +++ b/.github/workflows/check-readme.yaml @@ -19,8 +19,8 @@ jobs: fail-fast: false matrix: config: - #- { os: ubuntu-latest, r: "release" } - - { os: ubuntu-latest, r: "devel" } + - { os: ubuntu-latest, r: "release" } + #- { os: ubuntu-latest, r: "devel" } env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} @@ -32,7 +32,7 @@ jobs: # https://github.com/jgm/pandoc/releases - uses: r-lib/actions/setup-pandoc@v2 with: - pandoc-version: "3.1.2" + pandoc-version: "3.1.6" - uses: r-lib/actions/setup-r@v2 with: diff --git a/.github/workflows/check-spelling.yaml b/.github/workflows/check-spelling.yaml index e41a2ea96..fe4781714 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.2" + pandoc-version: "3.1.6" - 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 b9dfa2a2a..e3e897133 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.2" + pandoc-version: "3.1.6" - 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 ea33c1ca4..58f1f1413 100644 --- a/.github/workflows/pkgdown-no-suggests.yaml +++ b/.github/workflows/pkgdown-no-suggests.yaml @@ -27,7 +27,7 @@ jobs: # https://github.com/jgm/pandoc/releases - uses: r-lib/actions/setup-pandoc@v2 with: - pandoc-version: "3.1.2" + pandoc-version: "3.1.6" - uses: r-lib/actions/setup-r@v2 with: diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 6fcec2453..f3248bba5 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.2" + pandoc-version: "3.1.6" - 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.1 + uses: JamesIves/github-pages-deploy-action@v4.4.3 with: branch: gh-pages folder: docs diff --git a/.github/workflows/styler.yaml b/.github/workflows/styler.yaml index 0289fd7fb..e3807f9db 100644 --- a/.github/workflows/styler.yaml +++ b/.github/workflows/styler.yaml @@ -30,6 +30,7 @@ jobs: r-lib/pkgapi r-lib/styler r-lib/roxygen2 + anthonynorth/roxyglobals needs: | styler roxygen2 diff --git a/API b/API index 3dd0c4cf3..82ecf079f 100644 --- a/API +++ b/API @@ -7,14 +7,14 @@ extract_caption(p) extract_stats(p, ...) extract_subtitle(p) ggbarstats(data, x, y, counts = NULL, type = "parametric", paired = FALSE, results.subtitle = TRUE, label = "percentage", label.args = list(alpha = 1, fill = "white"), 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, xlab = NULL, ylab = NULL, ggtheme = ggstatsplot::theme_ggstatsplot(), package = "RColorBrewer", palette = "Dark2", ggplot.component = NULL, ...) -ggbetweenstats(data, x, y, type = "parametric", pairwise.comparisons = TRUE, 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.6), 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(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.6), 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, ...) ggcoefstats(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, color = "blue", na.rm = TRUE), errorbar.args = list(height = 0, na.rm = TRUE), vline = TRUE, vline.args = list(linewidth = 1, linetype = "dashed"), stats.labels = TRUE, stats.label.color = NULL, stats.label.args = list(size = 3, direction = "y", min.segment.length = 0), package = "RColorBrewer", palette = "Dark2", ggtheme = ggstatsplot::theme_ggstatsplot(), ...) ggcorrmat(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, ...) ggdotplotstats(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(), ...) gghistostats(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, ...) ggpiestats(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, ...) ggscatterstats(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 = 1e+06), 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, ...) -ggwithinstats(data, x, y, type = "parametric", pairwise.comparisons = TRUE, 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(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, ...) grouped_ggbarstats(data, ..., grouping.var, plotgrid.args = list(), annotation.args = list()) grouped_ggbetweenstats(data, ..., grouping.var, plotgrid.args = list(), annotation.args = list()) grouped_ggcorrmat(data, ..., grouping.var, plotgrid.args = list(), annotation.args = list()) diff --git a/CITATION.cff b/CITATION.cff index 3cec1b84f..3de2aa678 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -1,5 +1,5 @@ # ----------------------------------------------------------- -# CITATION file created with {cffr} R package, v0.4.1 +# CITATION file created with {cffr} R package, v0.5.0 # See also: https://docs.ropensci.org/cffr/ # ----------------------------------------------------------- @@ -8,7 +8,7 @@ message: 'To cite package "ggstatsplot" in publications use:' type: software license: GPL-3.0-only title: 'ggstatsplot: ''ggplot2'' Based Plots with Statistical Details' -version: 0.11.1.9000 +version: 0.12.0 doi: 10.21105/joss.03167 abstract: 'Extension of ''ggplot2'', ''ggstatsplot'' creates graphics with details from statistical tests included in the plots themselves. It provides an easier syntax @@ -106,7 +106,7 @@ references: abstract: 'datawizard: Easy Data Wrangling and Statistical Transformations' notes: Imports url: https://easystats.github.io/datawizard/ - repository: https://CRAN.R-project.org/package=datawizard + repository: https://easystats.r-universe.dev authors: - family-names: Patil given-names: Indrajeet @@ -133,7 +133,7 @@ references: email: brenton@wiernik.org orcid: https://orcid.org/0000-0001-9560-6336 year: '2023' - version: '>= 0.7.1' + version: '>= 0.8.0' - type: software title: dplyr abstract: 'dplyr: A Grammar of Data Manipulation' @@ -158,7 +158,7 @@ references: email: davis@posit.co orcid: https://orcid.org/0000-0003-4777-038X year: '2023' - version: '>= 1.1.1' + version: '>= 1.1.2' - type: software title: ggcorrplot abstract: 'ggcorrplot: Visualization of a Correlation Matrix using ''ggplot2''' @@ -249,6 +249,7 @@ references: email: patilindrajeet.science@gmail.com orcid: https://orcid.org/0000-0003-1995-6531 year: '2023' + version: '>= 0.6.4' - type: software title: glue abstract: 'glue: Interpreted String Literals' @@ -299,8 +300,12 @@ references: given-names: Vincent email: vincent.arel-bundock@umontreal.ca orcid: https://orcid.org/0000-0003-2042-7063 - version: '>= 0.19.1' + - family-names: Bacher + given-names: Etienne + email: etienne.bacher@protonmail.com + orcid: https://orcid.org/0000-0002-9271-5075 year: '2023' + version: '>= 0.19.3' - type: software title: paletteer abstract: 'paletteer: Comprehensive Collection of Color Palettes' @@ -316,7 +321,7 @@ references: abstract: 'parameters: Processing of Model Parameters' notes: Imports url: https://easystats.github.io/parameters/ - repository: https://CRAN.R-project.org/package=parameters + repository: https://easystats.r-universe.dev authors: - family-names: Lüdecke given-names: Daniel @@ -342,7 +347,7 @@ references: email: brenton@wiernik.org orcid: https://orcid.org/0000-0001-9560-6336 year: '2023' - version: '>= 0.20.3' + version: '>= 0.21.1' - type: software title: patchwork abstract: 'patchwork: The Composer of Plots' @@ -360,7 +365,7 @@ references: 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 @@ -387,7 +392,7 @@ references: email: brenton@wiernik.org orcid: https://orcid.org/0000-0001-9560-6336 year: '2023' - version: '>= 0.10.2' + version: '>= 0.10.4' - type: software title: purrr abstract: 'purrr: Functional Programming Tools' @@ -440,8 +445,8 @@ references: given-names: Indrajeet email: patilindrajeet.science@gmail.com orcid: https://orcid.org/0000-0003-1995-6531 + version: '>= 1.5.1' year: '2023' - version: '>= 1.5.0' - type: software title: tidyr abstract: 'tidyr: Tidy Messy Data' @@ -611,6 +616,7 @@ references: email: thorsten.pohlert@gmx.de orcid: https://orcid.org/0000-0003-3855-3025 year: '2023' + version: '>= 1.9.7' - type: software title: psych abstract: 'psych: Procedures for Psychological, Psychometric, and Personality Research' @@ -686,9 +692,9 @@ references: authors: - family-names: Wickham given-names: Hadley - email: hadley@rstudio.com + email: hadley@posit.co year: '2023' - version: '>= 3.1.7' + version: '>= 3.1.10' - type: software title: tibble abstract: 'tibble: Simple Data Frames' diff --git a/DESCRIPTION b/DESCRIPTION index 73de98072..a9a9a371e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: ggstatsplot Title: 'ggplot2' Based Plots with Statistical Details -Version: 0.11.1.9000 +Version: 0.12.0 Authors@R: c(person(given = "Indrajeet", family = "Patil", @@ -32,23 +32,23 @@ Depends: R (>= 4.1.0) Imports: correlation (>= 0.8.4), - datawizard (>= 0.7.1), - dplyr (>= 1.1.1), + datawizard (>= 0.8.0), + dplyr (>= 1.1.2), ggcorrplot (>= 0.1.4), ggplot2 (>= 3.4.2), ggrepel (>= 0.9.3), ggside (>= 0.2.2), - ggsignif, + ggsignif (>= 0.6.4), glue, - insight (>= 0.19.1), + insight (>= 0.19.3), paletteer, - parameters (>= 0.20.3), + parameters (>= 0.21.1), patchwork, - performance (>= 0.10.2), + performance (>= 0.10.4), purrr (>= 1.0.1), rlang, stats, - statsExpressions (>= 1.5.0), + statsExpressions (>= 1.5.1), tidyr, utils Suggests: @@ -61,11 +61,11 @@ Suggests: metaBMA, metafor, metaplus, - PMCMRplus, + PMCMRplus (>= 1.9.7), psych, rmarkdown, survival, - testthat (>= 3.1.7), + testthat (>= 3.1.10), tibble, vdiffr (>= 1.0.5), WRS2 @@ -75,9 +75,10 @@ Encoding: UTF-8 Language: en-US LazyData: true Roxygen: list( - markdown = TRUE, - roclets = c("rd", "namespace", "collate", "pkgapi::api_roclet") + markdown = TRUE, + roclets = c("collate", "namespace", "rd", "pkgapi::api_roclet", "roxyglobals::global_roclet") ) RoxygenNote: 7.2.3.9000 Config/testthat/edition: 3 Config/testthat/parallel: true +Config/Needs/check: anthonynorth/roxyglobals diff --git a/NEWS.md b/NEWS.md index 2db3b5267..68f77d49a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# ggstatsplot 0.11.1.9000 +# ggstatsplot 0.12.0 N.B. All statistical analysis in `{ggstatsplot}` is carried out in `{statsExpressions}`. Thus, to see changes related to statistical expressions, @@ -12,10 +12,15 @@ read the `NEWS` for that package: argument was also redundant. Since removing a specific geom is straightforward using `*.args` arguments. Examples for these two functions illustrate how. +- `ggbetweenstats()` and `ggwithinstats()` retire `pairwise.comparisons` + argument since it was redundant. In order to turn off showing pairwise + comparisons, you can now use `pairwise.display = "none"`. + ## NEW FEATURES - `ggbetweenstats()` gets `boxplot.args` argument to pass additional arguments - to the underlying geom function. + to the underlying geom function. This also fixes regression introduced in + `0.11.1` release where outlier points were displayed along with box plot. # ggstatsplot 0.11.1 diff --git a/R/combine_plots.R b/R/combine_plots.R index b6914d888..ceafb1223 100644 --- a/R/combine_plots.R +++ b/R/combine_plots.R @@ -20,10 +20,12 @@ #' @param ... Currently ignored. #' @inheritParams patchwork::wrap_plots #' +#' @autoglobal +#' #' @examples #' library(ggplot2) #' -#' # preparing the first plot +#' # first plot #' p1 <- ggplot( #' data = subset(iris, iris$Species == "setosa"), #' aes(x = Sepal.Length, y = Sepal.Width) @@ -31,7 +33,7 @@ #' geom_point() + #' labs(title = "setosa") #' -#' # preparing the second plot +#' # second plot #' p2 <- ggplot( #' data = subset(iris, iris$Species == "versicolor"), #' aes(x = Sepal.Length, y = Sepal.Width) diff --git a/R/extract_stats.R b/R/extract_stats.R index 9a03e6a7a..c176c321d 100644 --- a/R/extract_stats.R +++ b/R/extract_stats.R @@ -23,6 +23,8 @@ #' @param p A plot from `{ggstatsplot}` package #' @param ... Ignored #' +#' @autoglobal +#' #' @examplesIf identical(Sys.getenv("NOT_CRAN"), "true") && requireNamespace("PMCMRplus", quietly = TRUE) #' set.seed(123) #' diff --git a/R/ggbarstats.R b/R/ggbarstats.R index 3b1edf2e0..dc38f65c4 100644 --- a/R/ggbarstats.R +++ b/R/ggbarstats.R @@ -21,6 +21,8 @@ #' #' @inherit ggpiestats return details #' +#' @autoglobal +#' #' @examplesIf identical(Sys.getenv("NOT_CRAN"), "true") #' # for reproducibility #' set.seed(123) @@ -65,13 +67,11 @@ ggbarstats <- function(data, ...) { # data frame ------------------------------------------ - # convert entered stats type to a standard notation type <- stats_type_switch(type) # make sure both quoted and unquoted arguments are allowed c(x, y) %<-% c(ensym(x), ensym(y)) - # creating a data frame data %<>% select({{ x }}, {{ y }}, .counts = {{ counts }}) %>% tidyr::drop_na() @@ -89,7 +89,6 @@ ggbarstats <- function(data, # statistical analysis ------------------------------------------ if (results.subtitle) { - # relevant arguments for statistical tests .f.args <- list( data = data, x = {{ x }}, @@ -106,7 +105,7 @@ ggbarstats <- function(data, subtitle_df <- .eval_f(contingency_table, !!!.f.args, type = type) if (!is.null(subtitle_df)) subtitle <- subtitle_df$expression[[1L]] - # preparing Bayes Factor caption + # Bayes Factor caption if (type != "bayes" && bf.message && isFALSE(paired)) { caption_df <- .eval_f(contingency_table, !!!.f.args, type = "bayes") if (!is.null(caption_df)) caption <- caption_df$expression[[1L]] @@ -197,6 +196,8 @@ ggbarstats <- function(data, #' @inherit ggbarstats return details #' @inherit ggbarstats return return #' +#' @autoglobal +#' #' @examplesIf identical(Sys.getenv("NOT_CRAN"), "true") #' # for reproducibility #' set.seed(123) @@ -222,10 +223,7 @@ grouped_ggbarstats <- function(data, grouping.var, plotgrid.args = list(), annotation.args = list()) { - purrr::pmap( - .l = .grouped_list(data, {{ grouping.var }}), - .f = ggbarstats, - ... - ) %>% + .grouped_list(data, {{ grouping.var }}) %>% + purrr::pmap(.f = ggbarstats, ...) %>% combine_plots(plotgrid.args, annotation.args) } diff --git a/R/ggbetweenstats.R b/R/ggbetweenstats.R index cba79e7a8..8fbf6b37d 100644 --- a/R/ggbetweenstats.R +++ b/R/ggbetweenstats.R @@ -16,13 +16,6 @@ #' variable name for `x` will be used. #' @param ylab Labels for `y` axis variable. If `NULL` (default), #' variable name for `y` will be used. -#' @param pairwise.comparisons Logical that decides whether pairwise comparisons -#' are to be displayed (default: `TRUE`). Please note that only -#' **significant** comparisons will be shown by default. To change this -#' behavior, select appropriate option with `pairwise.display` argument. The -#' pairwise comparison dataframes are prepared using the -#' `pairwise_comparisons` function. For more details -#' about pairwise comparisons, see the documentation for that function. #' @param p.adjust.method Adjustment method for *p*-values for multiple #' comparisons. Possible methods are: `"holm"` (default), `"hochberg"`, #' `"hommel"`, `"bonferroni"`, `"BH"`, `"BY"`, `"fdr"`, `"none"`. @@ -34,7 +27,8 @@ #' #' You can use this argument to make sure that your plot is not uber-cluttered #' when you have multiple groups being compared and scores of pairwise -#' comparisons being displayed. +#' comparisons being displayed. If set to `"none"`, no pairwise comparisons +#' will be displayed. #' @param bf.message Logical that decides whether to display Bayes Factor in #' favor of the *null* hypothesis. This argument is relevant only **for #' parametric test** (Default: `TRUE`). @@ -107,6 +101,8 @@ #' @seealso \code{\link{grouped_ggbetweenstats}}, \code{\link{ggwithinstats}}, #' \code{\link{grouped_ggwithinstats}} #' +#' @autoglobal +#' #' @details For details, see: #' #' @@ -149,7 +145,6 @@ ggbetweenstats <- function(data, x, y, type = "parametric", - pairwise.comparisons = TRUE, pairwise.display = "significant", p.adjust.method = "holm", effsize.type = "unbiased", @@ -192,7 +187,7 @@ ggbetweenstats <- function(data, ...) { # data ----------------------------------- - # convert entered stats type to a standard notation + type <- stats_type_switch(type) # make sure both quoted and unquoted arguments are allowed @@ -209,7 +204,6 @@ ggbetweenstats <- function(data, test <- ifelse(nlevels(data %>% pull({{ x }})) < 3L, "t", "anova") if (results.subtitle) { - # relevant arguments for statistical tests .f.args <- list( data = data, x = as_string(x), @@ -238,7 +232,7 @@ ggbetweenstats <- function(data, plot <- ggplot(data, mapping = aes({{ x }}, {{ y }})) + exec(geom_point, aes(color = {{ x }}), !!!point.args) + - exec(geom_boxplot, outlier.shape = NA, !!!boxplot.args) + + exec(geom_boxplot, !!!boxplot.args, outlier.shape = NA) + exec(geom_violin, !!!violin.args) # centrality tagging ------------------------------------- @@ -261,7 +255,7 @@ ggbetweenstats <- function(data, seclabel <- NULL - if (isTRUE(pairwise.comparisons) && test == "anova") { + if (pairwise.display != "none" && test == "anova") { mpc_df <- pairwise_comparisons( data = data, x = {{ x }}, @@ -285,7 +279,7 @@ ggbetweenstats <- function(data, ggsignif.args = ggsignif.args ) - # preparing the secondary label axis to give pairwise comparisons test details + # secondary label axis to give pairwise comparisons test details seclabel <- .pairwise_seclabel( unique(mpc_df$test), ifelse(type == "bayes", "all", pairwise.display) @@ -326,6 +320,8 @@ ggbetweenstats <- function(data, #' @inheritParams combine_plots #' @inheritDotParams ggbetweenstats -title #' +#' @autoglobal +#' #' @seealso \code{\link{ggbetweenstats}}, \code{\link{ggwithinstats}}, #' \code{\link{grouped_ggwithinstats}} #' @@ -367,10 +363,7 @@ grouped_ggbetweenstats <- function(data, grouping.var, plotgrid.args = list(), annotation.args = list()) { - purrr::pmap( - .l = .grouped_list(data, {{ grouping.var }}), - .f = ggbetweenstats, - ... - ) %>% + .grouped_list(data, {{ grouping.var }}) %>% + purrr::pmap(.f = ggbetweenstats, ...) %>% combine_plots(plotgrid.args, annotation.args) } diff --git a/R/ggbetweenstats_helpers.R b/R/ggbetweenstats_helpers.R index b23c4bc9d..ead8406a1 100644 --- a/R/ggbetweenstats_helpers.R +++ b/R/ggbetweenstats_helpers.R @@ -7,6 +7,8 @@ #' @inheritParams ggwithinstats #' @inheritParams ggrepel::geom_label_repel #' +#' @autoglobal +#' #' @examples #' # this internal function may not have much utility outside of the package #' set.seed(123) @@ -29,13 +31,21 @@ x, y, centrality.path = FALSE, - centrality.path.args = list(linewidth = 1, color = "red", alpha = 0.5), + centrality.path.args = list( + linewidth = 1, + color = "red", + alpha = 0.5 + ), centrality.point.args = list(size = 5, color = "darkred"), - centrality.label.args = list(size = 3, nudge_x = 0.4, segment.linetype = 4), + centrality.label.args = list( + size = 3, + nudge_x = 0.4, + segment.linetype = 4 + ), ...) { centrality_df <- suppressWarnings(centrality_description(data, {{ x }}, {{ y }}, ...)) - # if there should be lines connecting mean values across groups + # lines connecting mean values across groups if (isTRUE(centrality.path)) { plot <- plot + exec( @@ -75,6 +85,8 @@ #' (produced by `pairwise_comparisons()` function). #' @inheritParams ggbetweenstats #' +#' @autoglobal +#' #' @examples #' set.seed(123) #' library(ggplot2) @@ -143,6 +155,7 @@ #' @inheritParams ggbetweenstats #' #' @keywords internal +#' @autoglobal #' @noRd .ggsignif_xy <- function(x, y) { # number of comparisons and size of each step @@ -180,6 +193,7 @@ #' @examples #' .pairwise_seclabel("my caption", "Student's t-test") #' @keywords internal +#' @autoglobal #' @noRd .pairwise_seclabel <- function(test.description, pairwise.display = "significant") { # single quote (') needs to be escaped inside glue expressions @@ -221,7 +235,7 @@ ggplot.component = NULL, ...) { # if no. of factor levels is greater than the default palette color count - .palette_message(package, palette, length(unique(levels(x)))[[1L]]) + .palette_message(package, palette, nlevels(x)) plot + labs( diff --git a/R/ggcoefstats.R b/R/ggcoefstats.R index 6dc4247fc..fffb86b6b 100644 --- a/R/ggcoefstats.R +++ b/R/ggcoefstats.R @@ -77,6 +77,8 @@ #' #' @inheritSection statsExpressions::meta_analysis Random-effects meta-analysis #' +#' @autoglobal +#' #' @note #' #' 1. In case you want to carry out meta-analysis, you will be asked to install @@ -176,9 +178,7 @@ ggcoefstats <- function(x, } # create a new term column if it's not present - if (!"term" %in% names(tidy_df)) { - tidy_df %<>% mutate(term = paste("term", row_number(), sep = "_")) - } + if (!"term" %in% names(tidy_df)) tidy_df %<>% mutate(term = paste("term", row_number(), sep = "_")) # check for duplicate terms and columns ------------------------- @@ -196,8 +196,7 @@ ggcoefstats <- function(x, # halt if there are still repeated terms if (anyDuplicated(tidy_df$term)) rlang::abort("Elements in `term` column must be unique.") - # if tidy data frame doesn't contain p-value or statistic column, a label - # can't be prepared + # if tidy data frame doesn't contain p-value or statistic column, no label if (!(all(c("p.value", "statistic") %in% names(tidy_df)))) stats.labels <- FALSE # CIs and intercepts ------------------------- @@ -211,10 +210,9 @@ ggcoefstats <- function(x, # whether to show model intercept if (exclude.intercept) tidy_df %<>% filter(!grepl("(Intercept)", term, TRUE)) - # preparing label ------------------------- + # label ------------------------- if (stats.labels) { - # add expression labels tidy_df %<>% tidy_model_expressions(statistic, k, effectsize.type) # only significant p-value labels are shown @@ -225,7 +223,6 @@ ggcoefstats <- function(x, # sorting ------------------------- - # whether the terms need to be sorted in specified order tidy_df %<>% parameters::sort_parameters(sort = sort, column = "estimate") # `term` needs to be a factor column; otherwise, ggplot2 will sort the x-axis @@ -244,7 +241,6 @@ ggcoefstats <- function(x, # meta analysis ------------------------- if (meta.analytic.effect) { - # standardizing type of statistics name meta.type <- stats_type_switch(meta.type) # results from frequentist random-effects meta-analysis @@ -263,7 +259,7 @@ ggcoefstats <- function(x, plot <- ggplot(tidy_df, mapping = aes(estimate, term)) + exec(geom_point, !!!point.args) - # if the confidence intervals are to be displayed on the plot + # adding confidence intervals if (conf.int) { plot <- plot + exec( @@ -274,7 +270,7 @@ ggcoefstats <- function(x, ) } - # if needed, adding the vertical line + # adding the vertical line if (vline) plot <- plot + exec(geom_vline, xintercept = 0, !!!vline.args) # ggrepel labels ------------------------- diff --git a/R/ggcorrmat.R b/R/ggcorrmat.R index b71b0e471..742df8b0e 100644 --- a/R/ggcorrmat.R +++ b/R/ggcorrmat.R @@ -46,6 +46,8 @@ #' #' @inheritSection statsExpressions::corr_test Correlation analyses #' +#' @autoglobal +#' #' @seealso \code{\link{grouped_ggcorrmat}} \code{\link{ggscatterstats}} #' \code{\link{grouped_ggscatterstats}} #' @@ -191,6 +193,8 @@ ggcorrmat <- function(data, #' @inheritParams grouped_ggbetweenstats #' @inheritDotParams ggcorrmat -title #' +#' @autoglobal +#' #' @seealso \code{\link{ggcorrmat}}, \code{\link{ggscatterstats}}, #' \code{\link{grouped_ggscatterstats}} #' @@ -214,10 +218,8 @@ grouped_ggcorrmat <- function(data, grouping.var, plotgrid.args = list(), annotation.args = list()) { - purrr::pmap( - .l = .grouped_list(data, {{ grouping.var }}), - .f = ggcorrmat, - ... - ) %>% # `guides = "keep"` is needed because each legend will be different + .grouped_list(data, {{ grouping.var }}) %>% + purrr::pmap(.f = ggcorrmat, ...) %>% + # `guides = "keep"` because legends can be different across grouping levels combine_plots(guides = "keep", plotgrid.args, annotation.args) } diff --git a/R/ggdotplotstats.R b/R/ggdotplotstats.R index 970561f58..43b1896b4 100644 --- a/R/ggdotplotstats.R +++ b/R/ggdotplotstats.R @@ -23,6 +23,8 @@ #' @seealso \code{\link{grouped_gghistostats}}, \code{\link{gghistostats}}, #' \code{\link{grouped_ggdotplotstats}} #' +#' @autoglobal +#' #' @details For details, see: #' #' @@ -71,7 +73,7 @@ ggdotplotstats <- function(data, ...) { # data ----------------------------------- - # convert entered stats type to a standard notation + type <- stats_type_switch(type) # ensure the variables work quoted or unquoted @@ -81,9 +83,7 @@ ggdotplotstats <- function(data, select({{ x }}, {{ y }}) %>% tidyr::drop_na() %>% mutate({{ y }} := droplevels(as.factor({{ y }}))) %>% - group_by({{ y }}) %>% - summarise({{ x }} := mean({{ x }})) %>% - ungroup() %>% + summarise({{ x }} := mean({{ x }}), .by = {{ y }}) %>% # rank ordering the data arrange({{ x }}) %>% mutate( @@ -94,7 +94,6 @@ ggdotplotstats <- function(data, # statistical analysis ------------------------------------------ if (results.subtitle) { - # relevant arguments for statistical tests .f.args <- list( data = data, x = {{ x }}, @@ -106,11 +105,11 @@ ggdotplotstats <- function(data, bf.prior = bf.prior ) - # preparing the subtitle with statistical results + # subtitle with statistical results subtitle_df <- .eval_f(one_sample_test, !!!.f.args, type = type) subtitle <- if (!is.null(subtitle_df)) subtitle_df$expression[[1L]] - # preparing the BF message + # BF message if (type == "parametric" && bf.message) { caption_df <- .eval_f(one_sample_test, !!!.f.args, type = "bayes") caption <- if (!is.null(caption_df)) caption_df$expression[[1L]] @@ -176,6 +175,8 @@ ggdotplotstats <- function(data, #' @seealso \code{\link{grouped_gghistostats}}, \code{\link{ggdotplotstats}}, #' \code{\link{gghistostats}} #' +#' @autoglobal +#' #' @inherit ggdotplotstats return references #' @inherit ggdotplotstats return details #' @@ -201,10 +202,7 @@ grouped_ggdotplotstats <- function(data, grouping.var, plotgrid.args = list(), annotation.args = list()) { - purrr::pmap( - .l = .grouped_list(data, {{ grouping.var }}), - .f = ggdotplotstats, - ... - ) %>% + .grouped_list(data, {{ grouping.var }}) %>% + purrr::pmap(.f = ggdotplotstats, ...) %>% combine_plots(plotgrid.args, annotation.args) } diff --git a/R/gghistostats.R b/R/gghistostats.R index 8f7696ba9..0f033bbe0 100644 --- a/R/gghistostats.R +++ b/R/gghistostats.R @@ -13,7 +13,7 @@ #' #' @param ... Currently ignored. #' @param normal.curve A logical value that decides whether to super-impose a -#' normal curve using `stats::dnorm(mean(x), sd(x))`. Default is `FALSE`. +#' normal curve using `stats::dnorm(mean(x), stats::sd(x))`. Default is `FALSE`. #' @param normal.curve.args A list of additional aesthetic arguments to be #' passed to the normal curve. #' @param binwidth The width of the histogram bins. Can be specified as a @@ -35,6 +35,8 @@ #' @seealso \code{\link{grouped_gghistostats}}, \code{\link{ggdotplotstats}}, #' \code{\link{grouped_ggdotplotstats}} #' +#' @autoglobal +#' #' @details For details, see: #' #' @@ -92,10 +94,9 @@ gghistostats <- function(data, # statistical analysis ------------------------------------------ if (results.subtitle) { - # convert entered stats type to a standard notation type <- stats_type_switch(type) - # relevant arguments for statistical tests + .f.args <- list( data = data, x = {{ x }}, @@ -107,11 +108,11 @@ gghistostats <- function(data, bf.prior = bf.prior ) - # preparing the subtitle with statistical results + # subtitle with statistical results subtitle_df <- .eval_f(one_sample_test, !!!.f.args, type = type) subtitle <- if (!is.null(subtitle_df)) subtitle_df$expression[[1L]] - # preparing the BF message + # BF message if (type == "parametric" && bf.message) { caption_df <- .eval_f(one_sample_test, !!!.f.args, type = "bayes") caption <- if (!is.null(caption_df)) caption_df$expression[[1L]] @@ -142,7 +143,7 @@ gghistostats <- function(data, exec( stat_function, fun = function(x, mean, sd, n, bw) stats::dnorm(x, mean, sd) * n * bw, - args = list(mean = mean(x_vec), sd = sd(x_vec), n = length(x_vec), bw = binwidth %||% .binwidth(x_vec)), + args = list(mean = mean(x_vec), sd = stats::sd(x_vec), n = length(x_vec), bw = binwidth %||% .binwidth(x_vec)), !!!normal.curve.args ) } @@ -195,6 +196,8 @@ gghistostats <- function(data, #' @seealso \code{\link{gghistostats}}, \code{\link{ggdotplotstats}}, #' \code{\link{grouped_ggdotplotstats}} #' +#' @autoglobal +#' #' @inherit gghistostats return references #' @inherit gghistostats return details #' @@ -219,12 +222,12 @@ grouped_gghistostats <- function(data, plotgrid.args = list(), annotation.args = list(), ...) { - purrr::pmap( - .l = .grouped_list(data, {{ grouping.var }}), - .f = gghistostats, - x = {{ x }}, - binwidth = binwidth %||% .binwidth(data %>% pull({{ x }})), - ... - ) %>% + .grouped_list(data, {{ grouping.var }}) %>% + purrr::pmap( + .f = gghistostats, + x = {{ x }}, + binwidth = binwidth %||% .binwidth(data %>% pull({{ x }})), + ... + ) %>% combine_plots(plotgrid.args, annotation.args) } diff --git a/R/gghistostats_helpers.R b/R/gghistostats_helpers.R index 6dec5fb4e..4f9216ea2 100644 --- a/R/gghistostats_helpers.R +++ b/R/gghistostats_helpers.R @@ -25,6 +25,7 @@ #' ) #' #' @keywords internal +#' @autoglobal #' @noRd .histo_labeller <- function(plot, x, centrality.line.args, ...) { # compute centrality measure (with a temporary data frame) diff --git a/R/ggpiestats.R b/R/ggpiestats.R index 71b349ce2..77edb228e 100644 --- a/R/ggpiestats.R +++ b/R/ggpiestats.R @@ -41,6 +41,8 @@ #' @seealso \code{\link{grouped_ggpiestats}}, \code{\link{ggbarstats}}, #' \code{\link{grouped_ggbarstats}} #' +#' @autoglobal +#' #' @details For details, see: #' #' @@ -91,7 +93,6 @@ ggpiestats <- function(data, ...) { # data frame ------------------------------------------ - # convert entered stats type to a standard notation type <- stats_type_switch(type) # ensure the variables work quoted or unquoted @@ -101,7 +102,6 @@ ggpiestats <- function(data, # one-way or two-way table? test <- ifelse(!quo_is_null(enquo(y)), "two.way", "one.way") - # creating a data frame data %<>% select({{ x }}, {{ y }}, .counts = {{ counts }}) %>% tidyr::drop_na() @@ -117,14 +117,13 @@ ggpiestats <- function(data, # TODO: one-way table in `BayesFactor` if (test == "two.way" && y_levels == 1L) bf.message <- FALSE - # faceting is possible only if both vars have more than one levels + # faceting is possible only if both vars have more than one level facet <- as.logical(y_levels > 1L) if ((x_levels == 1L && facet) || type == "bayes") proportion.test <- FALSE # statistical analysis ------------------------------------------ if (results.subtitle) { - # relevant arguments for statistical tests .f.args <- list( data = data, x = {{ x }}, @@ -141,7 +140,7 @@ ggpiestats <- function(data, subtitle_df <- .eval_f(contingency_table, !!!.f.args, type = type) if (!is.null(subtitle_df)) subtitle <- subtitle_df$expression[[1L]] - # preparing Bayes Factor caption + # Bayes Factor caption if (type != "bayes" && bf.message && isFALSE(paired)) { caption_df <- .eval_f(contingency_table, !!!.f.args, type = "bayes") if (!is.null(caption_df)) caption <- caption_df$expression[[1L]] @@ -153,7 +152,7 @@ ggpiestats <- function(data, # data frame with summary labels descriptive_df <- descriptive_data(data, {{ x }}, {{ y }}, label, perc.k) - # data frame containing all details needed for prop test + # data frame containing all details needed for proportion test if (test == "two.way") onesample_df <- onesample_data(data, {{ x }}, {{ y }}, k) # if no. of factor levels is greater than the default palette color count @@ -194,11 +193,7 @@ ggpiestats <- function(data, scale_y_continuous(breaks = NULL) + paletteer::scale_fill_paletteer_d(paste0(package, "::", palette), name = "") + ggtheme + - theme( - panel.grid = element_blank(), - axis.ticks = element_blank(), - axis.title = element_blank() - ) + + theme(panel.grid = element_blank(), axis.ticks = element_blank()) + guides(fill = guide_legend(override.aes = list(color = NA))) # sample size + proportion test ------------------------------------------ @@ -243,6 +238,8 @@ ggpiestats <- function(data, #' @seealso \code{\link{ggbarstats}}, \code{\link{ggpiestats}}, #' \code{\link{grouped_ggbarstats}} #' +#' @autoglobal +#' #' @inherit ggpiestats return references #' @inherit ggpiestats return details #' @inherit ggpiestats return return @@ -257,10 +254,7 @@ grouped_ggpiestats <- function(data, grouping.var, plotgrid.args = list(), annotation.args = list()) { - purrr::pmap( - .l = .grouped_list(data, {{ grouping.var }}), - .f = ggpiestats, - ... - ) %>% + .grouped_list(data, {{ grouping.var }}) %>% + purrr::pmap(.f = ggpiestats, ...) %>% combine_plots(plotgrid.args, annotation.args) } diff --git a/R/ggpiestats_ggbarstats_helpers.R b/R/ggpiestats_ggbarstats_helpers.R index b5b24c31a..c9b62b4a3 100644 --- a/R/ggpiestats_ggbarstats_helpers.R +++ b/R/ggpiestats_ggbarstats_helpers.R @@ -1,10 +1,11 @@ #' @title A data frame with descriptive labels +#' @autoglobal #' @noRd descriptive_data <- function(data, x, y = NULL, label.content = "percentage", - perc.k = 1, + perc.k = 1L, ...) { .cat_counter(data, {{ x }}, {{ y }}) %>% mutate( @@ -19,6 +20,7 @@ descriptive_data <- function(data, #' @title Counts and percentages across grouping variables +#' @autoglobal #' @noRd .cat_counter <- function(data, x, y = NULL, ...) { data %>% @@ -31,13 +33,14 @@ descriptive_data <- function(data, } #' @title A data frame with chi-squared test results +#' @autoglobal #' @noRd onesample_data <- function(data, x, y, k = 2L, ...) { full_join( - # descriptives + # descriptive summary x = .cat_counter(data, {{ y }}) %>% mutate(N = paste0("(n = ", .prettyNum(counts), ")")), - # proportion tests + # proportion test results y = group_by(data, {{ y }}) %>% group_modify(.f = ~ .chisq_test_safe(., {{ x }})) %>% ungroup(), @@ -45,20 +48,16 @@ onesample_data <- function(data, x, y, k = 2L, ...) { ) %>% rowwise() %>% mutate( - .label = paste0( - "list(~chi['gof']^2~", "(", df, ")==", format_value(statistic, k), - ", ~italic(p)=='", format_value(p.value, k), - "', ~italic(n)==", .prettyNum(counts), ")" - ), - .p.label = paste0("list(~italic(p)=='", format_value(p.value, k), "')") + .label = glue("list(~chi['gof']^2~({df})=={format_value(statistic, k)}, ~italic(p)=='{format_value(p.value, k)}', ~italic(n)=='{.prettyNum(counts)}')"), + .p.label = glue("list(~italic(p)=='{format_value(p.value, k)}')") ) %>% ungroup() } -# safer version of chi-squared test that returns NAs -# needed to work with `group_modify` since it will not work when NULL is returned -#' +#' Safer version of chi-squared test that returns `NA`s +#' Needed to work with `group_modify()` since it will not work when `NULL` is returned +#' @autoglobal #' @noRd .chisq_test_safe <- function(data, x, ...) { xtab <- table(data %>% pull({{ x }})) @@ -68,7 +67,6 @@ onesample_data <- function(data, x, y, k = 2L, ...) { error = function(e) NULL ) - # if not null, return tidy output, otherwise return NAs if (!is.null(result)) { as_tibble(insight::standardize_names(result, style = "broom")) } else { diff --git a/R/ggscatterstats.R b/R/ggscatterstats.R index 39e25276f..c5bba93cc 100644 --- a/R/ggscatterstats.R +++ b/R/ggscatterstats.R @@ -46,6 +46,8 @@ #' @seealso \code{\link{grouped_ggscatterstats}}, \code{\link{ggcorrmat}}, #' \code{\link{grouped_ggcorrmat}} #' +#' @autoglobal +#' #' @details For details, see: #' #' @@ -108,16 +110,15 @@ ggscatterstats <- function(data, # ensure the arguments work quoted or unquoted c(x, y) %<-% c(ensym(x), ensym(y)) - # preparing the data frame + # data frame data %<>% filter(!is.na({{ x }}), !is.na({{ y }})) # statistical analysis ------------------------------------------ if (results.subtitle) { - # convert entered stats type to a standard notation type <- stats_type_switch(type) - # relevant arguments for statistical tests + .f.args <- list( data = data, x = {{ x }}, @@ -131,7 +132,7 @@ ggscatterstats <- function(data, subtitle_df <- .eval_f(corr_test, !!!.f.args, type = type) subtitle <- if (!is.null(subtitle_df)) subtitle_df$expression[[1L]] - # preparing the BF message for null hypothesis support + # BF message for null hypothesis support if (type == "parametric" && bf.message) { caption_df <- .eval_f(corr_test, !!!.f.args, type = "bayes") caption <- if (!is.null(caption_df)) caption_df$expression[[1L]] @@ -143,7 +144,7 @@ ggscatterstats <- function(data, # creating jittered positions pos <- position_jitter(width = point.width.jitter, height = point.height.jitter) - # preparing the scatterplot + # scatterplot plotScatter <- ggplot(data, mapping = aes({{ x }}, {{ y }})) + exec(geom_point, position = pos, !!!point.args) + exec(geom_smooth, level = conf.level, !!!smooth.line.args, na.rm = TRUE) @@ -211,6 +212,8 @@ ggscatterstats <- function(data, #' @seealso \code{\link{ggscatterstats}}, \code{\link{ggcorrmat}}, #' \code{\link{grouped_ggcorrmat}} #' +#' @autoglobal +#' #' @inherit ggscatterstats return references #' @inherit ggscatterstats return details #' @@ -260,10 +263,7 @@ grouped_ggscatterstats <- function(data, grouping.var, plotgrid.args = list(), annotation.args = list()) { - purrr::pmap( - .l = .grouped_list(data, {{ grouping.var }}), - .f = ggscatterstats, - ... - ) %>% + .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 80767c3c1..dbbfbc91e 100644 --- a/R/ggwithinstats.R +++ b/R/ggwithinstats.R @@ -32,6 +32,8 @@ #' @seealso \code{\link{grouped_ggbetweenstats}}, \code{\link{ggbetweenstats}}, #' \code{\link{grouped_ggwithinstats}} #' +#' @autoglobal +#' #' @details For details, see: #' #' @@ -80,7 +82,6 @@ ggwithinstats <- function(data, x, y, type = "parametric", - pairwise.comparisons = TRUE, pairwise.display = "significant", p.adjust.method = "holm", effsize.type = "unbiased", @@ -118,16 +119,14 @@ ggwithinstats <- function(data, # ensure the variables work quoted or unquoted c(x, y) %<-% c(ensym(x), ensym(y)) - # convert entered stats type to a standard notation + type <- stats_type_switch(type) - # creating a data frame + data %<>% select({{ x }}, {{ y }}) %>% mutate({{ x }} := droplevels(as.factor({{ x }}))) %>% - group_by({{ x }}) %>% - mutate(.rowid = row_number()) %>% - ungroup() %>% + mutate(.rowid = row_number(), .by = {{ x }}) %>% anti_join(x = ., y = filter(., is.na({{ y }})), by = ".rowid") # statistical analysis ------------------------------------------ @@ -136,7 +135,6 @@ ggwithinstats <- function(data, test <- ifelse(nlevels(data %>% pull({{ x }})) < 3L, "t", "anova") if (results.subtitle && insight::check_if_installed("afex")) { - # relevant arguments for statistical tests .f.args <- list( data = data, x = as_string(x), @@ -168,7 +166,7 @@ ggwithinstats <- function(data, plot <- ggplot(data, aes({{ x }}, {{ y }}, group = .rowid)) + exec(geom_point, aes(color = {{ x }}), !!!point.args) + - exec(geom_boxplot, aes({{ x }}, {{ y }}), inherit.aes = FALSE, outlier.shape = NA, !!!boxplot.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 @@ -197,7 +195,7 @@ ggwithinstats <- function(data, # initialize seclabel <- NULL - if (isTRUE(pairwise.comparisons) && test == "anova") { + if (pairwise.display != "none" && test == "anova") { mpc_df <- pairwise_comparisons( data = data, x = {{ x }}, @@ -220,7 +218,7 @@ ggwithinstats <- function(data, ggsignif.args = ggsignif.args ) - # preparing the secondary label axis to give pairwise comparisons test details + # secondary label axis to give pairwise comparisons test details seclabel <- .pairwise_seclabel( unique(mpc_df$test), ifelse(type == "bayes", "all", pairwise.display) @@ -261,6 +259,8 @@ ggwithinstats <- function(data, #' @seealso \code{\link{ggwithinstats}}, \code{\link{ggbetweenstats}}, #' \code{\link{grouped_ggbetweenstats}} #' +#' @autoglobal +#' #' @inherit ggwithinstats return references #' #' @examplesIf identical(Sys.getenv("NOT_CRAN"), "true") && requireNamespace("afex", quietly = TRUE) @@ -285,10 +285,7 @@ grouped_ggwithinstats <- function(data, grouping.var, plotgrid.args = list(), annotation.args = list()) { - purrr::pmap( - .l = .grouped_list(data, {{ grouping.var }}), - .f = ggwithinstats, - ... - ) %>% + .grouped_list(data, {{ grouping.var }}) %>% + purrr::pmap(.f = ggwithinstats, ...) %>% combine_plots(plotgrid.args, annotation.args) } diff --git a/R/global_vars.R b/R/global_vars.R deleted file mode 100644 index cac51c035..000000000 --- a/R/global_vars.R +++ /dev/null @@ -1,45 +0,0 @@ -# defining global variables and functions to appease R CMD Check - -utils::globalVariables( - names = c( - ".", - "N", - "conf.high", - "conf.low", - "count", - "counts", - "df.error", - "estimate", - "group1", - "group2", - "label", - "median", - "p.value", - "parameter", - "perc", - "rowid", - ".rowid", - "sd", - "significance", - "statistic", - "std.error", - "term", - "df", - ".label", - ".counts", - ".p.label", - "trimmed.mean", - "group", - "r.method", - "r.method.text", - ".x", - "var", - "renderPlot", - ".f", - ".fn", - ".ns", - "log_e_bf10" - ), - package = "ggstatsplot", - add = FALSE -) diff --git a/R/globals.R b/R/globals.R new file mode 100644 index 000000000..bc07fee41 --- /dev/null +++ b/R/globals.R @@ -0,0 +1,28 @@ +# Generated by roxyglobals: do not edit by hand + +utils::globalVariables(c( + ".counts", # + "perc", # + ".label", # + ".p.label", # + "N", # + "group1", # <.ggsignif_adder> + "group2", # <.ggsignif_adder> + "p.value", # <.ggsignif_adder> + "term", # + "p.value", # + "estimate", # + "conf.low", # + "conf.high", # + ".x", # <.histo_labeller> + "var", # <.histo_labeller> + ".counts", # + "perc", # + ".label", # + "counts", # <.cat_counter> + "counts", # + ".", # + ".rowid", # + ".", # <.grouped_list> + NULL +)) diff --git a/R/utils.R b/R/utils.R index cb3611994..65c9e9ef1 100644 --- a/R/utils.R +++ b/R/utils.R @@ -8,6 +8,7 @@ #' @inheritParams ggbetweenstats #' @param grouping.var A single grouping variable. #' +#' @autoglobal #' @examplesIf identical(Sys.getenv("NOT_CRAN"), "true") #' ggstatsplot:::.grouped_list(ggplot2::msleep, grouping.var = vore) #' @keywords internal @@ -29,6 +30,7 @@ #' @description Informs the user about not using the default color palette #' when the number of factor levels is greater than 8, the maximum number of #' colors allowed by `"Dark2"` palette from the `RColorBrewer` package. +#' @autoglobal #' @noRd .palette_message <- function(package, palette, min_length) { palette_length <- paletteer::palettes_d_names %>% diff --git a/README.md b/README.md index bad23c121..5e416084e 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,6 @@ context, run the following code in your `R` console: ``` r citation("ggstatsplot") - To cite package 'ggstatsplot' in publications use: Patil, I. (2021). Visualizations with statistical details: The diff --git a/WIP/ggridgestats.R b/WIP/ggridgestats.R index bb52d8dbd..3279dae3d 100644 --- a/WIP/ggridgestats.R +++ b/WIP/ggridgestats.R @@ -19,7 +19,6 @@ ggridgestats <- function(data, y, type = "parametric", paired = FALSE, - pairwise.comparisons = TRUE, pairwise.display = "significant", p.adjust.method = "holm", effsize.type = "unbiased", @@ -60,13 +59,13 @@ ggridgestats <- function(data, ...) { # data ----------------------------------- - # convert entered stats type to a standard notation + type <- statsExpressions::stats_type_switch(type) # make sure both quoted and unquoted arguments are allowed c(x, y) %<-% c(rlang::ensym(x), rlang::ensym(y)) - # creating a data frame + data %<>% dplyr::select({{ x }}, {{ y }}) %>% tidyr::drop_na() %>% @@ -78,7 +77,7 @@ ggridgestats <- function(data, test <- ifelse(nlevels(data %>% dplyr::pull({{ x }})) < 3, "t", "anova") if (results.subtitle) { - # relevant arguments for statistical tests + .f.args <- list( data = data, x = rlang::as_string(x), @@ -97,7 +96,7 @@ ggridgestats <- function(data, subtitle_df <- .eval_f(.f, !!!.f.args, type = type) subtitle <- if (!is.null(subtitle_df)) subtitle_df$expression[[1L]] - # preparing the Bayes factor message + # Bayes factor message if (type == "parametric" && bf.message) { caption_df <- .eval_f(.f, !!!.f.args, type = "bayes") caption <- if (!is.null(caption_df)) caption_df$expression[[1L]] @@ -164,7 +163,7 @@ ggridgestats <- function(data, # ggsignif labels ------------------------------------- - if (isTRUE(pairwise.comparisons) && test == "anova") { + if (pairwise.display != "none" && test == "anova") { # creating data frame with pairwise comparison results mpc_df <- pairwise_comparisons( data = data, @@ -190,7 +189,7 @@ ggridgestats <- function(data, y_start_jitter = 0.2 ) - # preparing the caption for pairwise comparisons test + # caption for pairwise comparisons test caption <- .pairwise_seclabel( caption, unique(mpc_df$test), diff --git a/codemeta.json b/codemeta.json index a9ee5386f..552a26a07 100644 --- a/codemeta.json +++ b/codemeta.json @@ -8,13 +8,13 @@ "codeRepository": "https://github.com/IndrajeetPatil/ggstatsplot", "issueTracker": "https://github.com/IndrajeetPatil/ggstatsplot/issues", "license": "https://spdx.org/licenses/GPL-3.0", - "version": "0.11.1.9000", + "version": "0.12.0", "programmingLanguage": { "@type": "ComputerLanguage", "name": "R", "url": "https://r-project.org" }, - "runtimePlatform": "R version 4.2.2 (2022-10-31)", + "runtimePlatform": "R version 4.3.1 (2023-06-16)", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", @@ -171,6 +171,7 @@ "@type": "SoftwareApplication", "identifier": "PMCMRplus", "name": "PMCMRplus", + "version": ">= 1.9.7", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", @@ -219,7 +220,7 @@ "@type": "SoftwareApplication", "identifier": "testthat", "name": "testthat", - "version": ">= 3.1.7", + "version": ">= 3.1.10", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", @@ -290,7 +291,7 @@ "@type": "SoftwareApplication", "identifier": "datawizard", "name": "datawizard", - "version": ">= 0.7.1", + "version": ">= 0.8.0", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", @@ -303,7 +304,7 @@ "@type": "SoftwareApplication", "identifier": "dplyr", "name": "dplyr", - "version": ">= 1.1.1", + "version": ">= 1.1.2", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", @@ -368,6 +369,7 @@ "@type": "SoftwareApplication", "identifier": "ggsignif", "name": "ggsignif", + "version": ">= 0.6.4", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", @@ -392,7 +394,7 @@ "@type": "SoftwareApplication", "identifier": "insight", "name": "insight", - "version": ">= 0.19.1", + "version": ">= 0.19.3", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", @@ -417,7 +419,7 @@ "@type": "SoftwareApplication", "identifier": "parameters", "name": "parameters", - "version": ">= 0.20.3", + "version": ">= 0.21.1", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", @@ -442,7 +444,7 @@ "@type": "SoftwareApplication", "identifier": "performance", "name": "performance", - "version": ">= 0.10.2", + "version": ">= 0.10.4", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", @@ -485,7 +487,7 @@ "@type": "SoftwareApplication", "identifier": "statsExpressions", "name": "statsExpressions", - "version": ">= 1.5.0", + "version": ">= 1.5.1", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", @@ -513,7 +515,7 @@ }, "SystemRequirements": null }, - "fileSize": "9198.026KB", + "fileSize": "9401.95KB", "citation": [ { "@type": "ScholarlyArticle", diff --git a/cran-comments.md b/cran-comments.md index 92ae0c7e4..5f724bbe4 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -2,7 +2,7 @@ 0 errors | 0 warnings | 0 note -- Fix breaking change caused by `{parameters}` updates. +- Maintenance release. ## revdepcheck results diff --git a/man/combine_plots.Rd b/man/combine_plots.Rd index 1ed832e13..4b85183e5 100644 --- a/man/combine_plots.Rd +++ b/man/combine_plots.Rd @@ -46,7 +46,7 @@ is exported only for backward compatibility. \examples{ library(ggplot2) -# preparing the first plot +# first plot p1 <- ggplot( data = subset(iris, iris$Species == "setosa"), aes(x = Sepal.Length, y = Sepal.Width) @@ -54,7 +54,7 @@ p1 <- ggplot( geom_point() + labs(title = "setosa") -# preparing the second plot +# second plot p2 <- ggplot( data = subset(iris, iris$Species == "versicolor"), aes(x = Sepal.Length, y = Sepal.Width) diff --git a/man/figures/README-ggbetweenstats1-1.png b/man/figures/README-ggbetweenstats1-1.png index 1748a52c8..4a390343a 100644 Binary files a/man/figures/README-ggbetweenstats1-1.png and b/man/figures/README-ggbetweenstats1-1.png differ diff --git a/man/figures/README-ggbetweenstats2-1.png b/man/figures/README-ggbetweenstats2-1.png index 592637ae9..4a98d9724 100644 Binary files a/man/figures/README-ggbetweenstats2-1.png and b/man/figures/README-ggbetweenstats2-1.png differ diff --git a/man/figures/README-ggwithinstats1-1.png b/man/figures/README-ggwithinstats1-1.png index 424e896f5..1079acb3d 100644 Binary files a/man/figures/README-ggwithinstats1-1.png and b/man/figures/README-ggwithinstats1-1.png differ diff --git a/man/figures/README-ggwithinstats2-1.png b/man/figures/README-ggwithinstats2-1.png index 487057915..29760a167 100644 Binary files a/man/figures/README-ggwithinstats2-1.png and b/man/figures/README-ggwithinstats2-1.png differ diff --git a/man/ggbetweenstats.Rd b/man/ggbetweenstats.Rd index 0dc10a1d4..f45655524 100644 --- a/man/ggbetweenstats.Rd +++ b/man/ggbetweenstats.Rd @@ -9,7 +9,6 @@ ggbetweenstats( x, y, type = "parametric", - pairwise.comparisons = TRUE, pairwise.display = "significant", p.adjust.method = "holm", effsize.type = "unbiased", @@ -70,14 +69,6 @@ subject-1,subject-2, ..., pattern.} You can specify just the initial letter.} -\item{pairwise.comparisons}{Logical that decides whether pairwise comparisons -are to be displayed (default: \code{TRUE}). Please note that only -\strong{significant} comparisons will be shown by default. To change this -behavior, select appropriate option with \code{pairwise.display} argument. The -pairwise comparison dataframes are prepared using the -\code{pairwise_comparisons} function. For more details -about pairwise comparisons, see the documentation for that function.} - \item{pairwise.display}{Decides \emph{which} pairwise comparisons to display. Available options are: \itemize{ @@ -88,7 +79,8 @@ Available options are: You can use this argument to make sure that your plot is not uber-cluttered when you have multiple groups being compared and scores of pairwise -comparisons being displayed.} +comparisons being displayed. If set to \code{"none"}, no pairwise comparisons +will be displayed.} \item{p.adjust.method}{Adjustment method for \emph{p}-values for multiple comparisons. Possible methods are: \code{"holm"} (default), \code{"hochberg"}, diff --git a/man/gghistostats.Rd b/man/gghistostats.Rd index c1bf6cdd0..36af3bae4 100644 --- a/man/gghistostats.Rd +++ b/man/gghistostats.Rd @@ -145,7 +145,7 @@ passed to the \code{geom_line} used to display the lines corresponding to the centrality parameter.} \item{normal.curve}{A logical value that decides whether to super-impose a -normal curve using \code{stats::dnorm(mean(x), sd(x))}. Default is \code{FALSE}.} +normal curve using \code{stats::dnorm(mean(x), stats::sd(x))}. Default is \code{FALSE}.} \item{normal.curve.args}{A list of additional aesthetic arguments to be passed to the normal curve.} diff --git a/man/ggwithinstats.Rd b/man/ggwithinstats.Rd index 1f56b03e6..f93300310 100644 --- a/man/ggwithinstats.Rd +++ b/man/ggwithinstats.Rd @@ -9,7 +9,6 @@ ggwithinstats( x, y, type = "parametric", - pairwise.comparisons = TRUE, pairwise.display = "significant", p.adjust.method = "holm", effsize.type = "unbiased", @@ -71,14 +70,6 @@ subject-1,subject-2, ..., pattern.} You can specify just the initial letter.} -\item{pairwise.comparisons}{Logical that decides whether pairwise comparisons -are to be displayed (default: \code{TRUE}). Please note that only -\strong{significant} comparisons will be shown by default. To change this -behavior, select appropriate option with \code{pairwise.display} argument. The -pairwise comparison dataframes are prepared using the -\code{pairwise_comparisons} function. For more details -about pairwise comparisons, see the documentation for that function.} - \item{pairwise.display}{Decides \emph{which} pairwise comparisons to display. Available options are: \itemize{ @@ -89,7 +80,8 @@ Available options are: You can use this argument to make sure that your plot is not uber-cluttered when you have multiple groups being compared and scores of pairwise -comparisons being displayed.} +comparisons being displayed. If set to \code{"none"}, no pairwise comparisons +will be displayed.} \item{p.adjust.method}{Adjustment method for \emph{p}-values for multiple comparisons. Possible methods are: \code{"holm"} (default), \code{"hochberg"}, diff --git a/man/grouped_ggbetweenstats.Rd b/man/grouped_ggbetweenstats.Rd index 20379511f..391d19de6 100644 --- a/man/grouped_ggbetweenstats.Rd +++ b/man/grouped_ggbetweenstats.Rd @@ -26,13 +26,6 @@ ungrouped before they are entered as \code{data}.} variable name for \code{x} will be used.} \item{\code{ylab}}{Labels for \code{y} axis variable. If \code{NULL} (default), variable name for \code{y} will be used.} - \item{\code{pairwise.comparisons}}{Logical that decides whether pairwise comparisons -are to be displayed (default: \code{TRUE}). Please note that only -\strong{significant} comparisons will be shown by default. To change this -behavior, select appropriate option with \code{pairwise.display} argument. The -pairwise comparison dataframes are prepared using the -\code{pairwise_comparisons} function. For more details -about pairwise comparisons, see the documentation for that function.} \item{\code{p.adjust.method}}{Adjustment method for \emph{p}-values for multiple comparisons. Possible methods are: \code{"holm"} (default), \code{"hochberg"}, \code{"hommel"}, \code{"bonferroni"}, \code{"BH"}, \code{"BY"}, \code{"fdr"}, \code{"none"}.} @@ -46,7 +39,8 @@ Available options are: You can use this argument to make sure that your plot is not uber-cluttered when you have multiple groups being compared and scores of pairwise -comparisons being displayed.} +comparisons being displayed. If set to \code{"none"}, no pairwise comparisons +will be displayed.} \item{\code{bf.message}}{Logical that decides whether to display Bayes Factor in favor of the \emph{null} hypothesis. This argument is relevant only \strong{for parametric test} (Default: \code{TRUE}).} diff --git a/man/grouped_gghistostats.Rd b/man/grouped_gghistostats.Rd index a4946a00e..e92a46ea3 100644 --- a/man/grouped_gghistostats.Rd +++ b/man/grouped_gghistostats.Rd @@ -41,7 +41,7 @@ separately specified here.} Arguments passed on to \code{\link[=gghistostats]{gghistostats}} \describe{ \item{\code{normal.curve}}{A logical value that decides whether to super-impose a -normal curve using \code{stats::dnorm(mean(x), sd(x))}. Default is \code{FALSE}.} +normal curve using \code{stats::dnorm(mean(x), stats::sd(x))}. Default is \code{FALSE}.} \item{\code{normal.curve.args}}{A list of additional aesthetic arguments to be passed to the normal curve.} \item{\code{bin.args}}{A list of additional aesthetic arguments to be passed to the diff --git a/man/grouped_ggwithinstats.Rd b/man/grouped_ggwithinstats.Rd index a974f3766..8fe0b80aa 100644 --- a/man/grouped_ggwithinstats.Rd +++ b/man/grouped_ggwithinstats.Rd @@ -35,13 +35,6 @@ and mean points.} variable name for \code{x} will be used.} \item{\code{ylab}}{Labels for \code{y} axis variable. If \code{NULL} (default), variable name for \code{y} will be used.} - \item{\code{pairwise.comparisons}}{Logical that decides whether pairwise comparisons -are to be displayed (default: \code{TRUE}). Please note that only -\strong{significant} comparisons will be shown by default. To change this -behavior, select appropriate option with \code{pairwise.display} argument. The -pairwise comparison dataframes are prepared using the -\code{pairwise_comparisons} function. For more details -about pairwise comparisons, see the documentation for that function.} \item{\code{p.adjust.method}}{Adjustment method for \emph{p}-values for multiple comparisons. Possible methods are: \code{"holm"} (default), \code{"hochberg"}, \code{"hommel"}, \code{"bonferroni"}, \code{"BH"}, \code{"BY"}, \code{"fdr"}, \code{"none"}.} @@ -55,7 +48,8 @@ Available options are: You can use this argument to make sure that your plot is not uber-cluttered when you have multiple groups being compared and scores of pairwise -comparisons being displayed.} +comparisons being displayed. If set to \code{"none"}, no pairwise comparisons +will be displayed.} \item{\code{bf.message}}{Logical that decides whether to display Bayes Factor in favor of the \emph{null} hypothesis. This argument is relevant only \strong{for parametric test} (Default: \code{TRUE}).} diff --git a/old/ggcoefstats_old.Rmd b/old/ggcoefstats_old.Rmd index 09f8be537..27203bfe6 100644 --- a/old/ggcoefstats_old.Rmd +++ b/old/ggcoefstats_old.Rmd @@ -3018,7 +3018,6 @@ ggcoefstats( library(survey) data(api) -# preparing data dclus1 <- survey::svydesign( id = ~dnum, @@ -4086,7 +4085,6 @@ ggcoefstats( library(quantreg) -# preparing data Dat <- NULL Dat$x <- rep(1:25, 20) Dat$y <- stats::SSlogis(Dat$x, 10, 12, 2) * rnorm(500, 1, 0.1) @@ -4502,7 +4500,7 @@ used to selectively show few of the terms of interest: library(glmnet) set.seed(2014) -# creating a data frame + x <- matrix(rnorm(100 * 20), 100, 20) y <- rnorm(100) fit1 <- glmnet::glmnet(x, y) diff --git a/revdep/README.md b/revdep/README.md index 8933bd828..290c67c34 100644 --- a/revdep/README.md +++ b/revdep/README.md @@ -86,7 +86,7 @@ |stringi |1.7.5 |1.7.5 | | |stringr |1.4.0 |1.4.0 | | |SuppDists |1.1-9.5 |1.1-9.5 | | -|tibble |3.1.5 |3.1.5 | | +|tibble |3.1.6 |3.1.6 | | |tidyr |1.1.4 |1.1.4 | | |tidyselect |1.1.1 |1.1.1 | | |utf8 |1.2.2 |1.2.2 | | diff --git a/tests/testthat.R b/tests/testthat.R index 51d316402..019ff18ff 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -1,6 +1,6 @@ # graphics engine changed in this version, and so snapshots generated on # previous R version won't work -if (getRversion() > "4.1.0") { +if (getRversion() > "4.1.0" && getRversion() < "4.4.0") { library(testthat) suppressPackageStartupMessages(library(ggstatsplot)) diff --git a/tests/testthat/_snaps/ggbetweenstats/plot-with-outliers-as-expected.svg b/tests/testthat/_snaps/ggbetweenstats/plot-with-outliers-as-expected.svg new file mode 100644 index 000000000..0d192f578 --- /dev/null +++ b/tests/testthat/_snaps/ggbetweenstats/plot-with-outliers-as-expected.svg @@ -0,0 +1,864 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +μ + +m +e +a +n += +116.27 + +μ + +m +e +a +n += +116.69 + +μ + +m +e +a +n += +102.38 +p +Bonferroni +− +a +d +j +. += +1.27e-03 + + + + + +100 +150 +200 +250 + + + + + + + +PG +(n = 15) +PG-13 +(n = 72) +R +(n = 99) +mpaa +length +Pairwise test: + +Games-Howell +, + +Bars shown: + +significant +F +Welch +( +2 +, + +36.91 +) += +10.58 +, + +p += +2.33e-04 +, + +ω +p +2 + += +0.32 +, + +C +I +95% + +[ +0.11 +, + +1.00 +] +, + +n +obs += +186 +Action +l +o +g +e +( +B +F +01 +) += +-6.41 +, + +R +2 + +Bayesian +posterior += +0.10 +, + +C +I +95% +H +D +I + +[ +0.03 +, + +0.18 +] +, + +r +Cauchy +JZS += +0.71 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +μ + +m +e +a +n += +92.57 + +μ + +m +e +a +n += +97.32 + +μ + +m +e +a +n += +95.55 + + +80 +100 +120 +140 +160 + + + + + + + + +PG +(n = 49) +PG-13 +(n = 92) +R +(n = 119) +mpaa +length +Pairwise test: + +Games-Howell +, + +Bars shown: + +significant +F +Welch +( +2 +, + +142.56 +) += +4.34 +, + +p += +0.01 +, + +ω +p +2 + += +0.04 +, + +C +I +95% + +[ +9.85e-04 +, + +1.00 +] +, + +n +obs += +260 +Comedy +l +o +g +e +( +B +F +01 +) += +0.80 +, + +R +2 + +Bayesian +posterior += +0.00 +, + +C +I +95% +H +D +I + +[ +0.00 +, + +0.05 +] +, + +r +Cauchy +JZS += +0.71 +Differences in movie length by mpaa ratings for different genres + + diff --git a/tests/testthat/test-extract_stats.R b/tests/testthat/test-extract_stats.R index a6d6273cd..48c41b5ae 100644 --- a/tests/testthat/test-extract_stats.R +++ b/tests/testthat/test-extract_stats.R @@ -2,6 +2,7 @@ test_that( desc = "checking if extract_stats works", code = { skip_if_not_installed("PMCMRplus") + skip_if_not_installed("rstantools") options(tibble.width = Inf) set.seed(123) diff --git a/tests/testthat/test-ggbetweenstats.R b/tests/testthat/test-ggbetweenstats.R index 3b1b35ccb..5a8d4e28d 100644 --- a/tests/testthat/test-ggbetweenstats.R +++ b/tests/testthat/test-ggbetweenstats.R @@ -1,5 +1,6 @@ # pairwise comparisons testing is done `test-pairwise_ggsignif.R` skip_if_not_installed("PMCMRplus") +skip_if_not_installed("rstantools") # checking labels and data from plot ------------------------------------- @@ -13,7 +14,7 @@ test_that( data = mtcars, x = am, y = wt, - pairwise.comparisons = FALSE, + pairwise.display = "none", results.subtitle = FALSE ) + ggplot2::labs(x = "Transmission", y = "Weight") @@ -32,7 +33,7 @@ test_that( data = df_small, x = group, y = centrality.a, - pairwise.comparisons = FALSE, + pairwise.display = "none", results.subtitle = FALSE )) ) @@ -112,5 +113,22 @@ test_that( ggplot.component = ggplot2::labs(x = "Movie Genre") ) ) + + set.seed(123) + expect_doppelganger( + title = "plot with outliers as expected", + fig = grouped_ggbetweenstats( + data = dplyr::filter(movies_long, genre %in% c("Action", "Comedy")), + x = mpaa, + y = length, + grouping.var = genre, + ggsignif.args = list(textsize = 4, tip_length = 0.01), + p.adjust.method = "bonferroni", + palette = "default_jama", + package = "ggsci", + plotgrid.args = list(nrow = 1), + annotation.args = list(title = "Differences in movie length by mpaa ratings for different genres") + ) + ) } ) diff --git a/tests/testthat/test-ggdotplotstats.R b/tests/testthat/test-ggdotplotstats.R index 96a4d9fef..9b7b4ad09 100644 --- a/tests/testthat/test-ggdotplotstats.R +++ b/tests/testthat/test-ggdotplotstats.R @@ -65,7 +65,6 @@ test_that( test_that( desc = "subtitle output", code = { - # should output a list of length 3 set.seed(123) p_sub_ggdot <- suppressWarnings(ggdotplotstats( data = morley, diff --git a/tests/testthat/test-gghistostats.R b/tests/testthat/test-gghistostats.R index 327a77be4..c02ae14ff 100644 --- a/tests/testthat/test-gghistostats.R +++ b/tests/testthat/test-gghistostats.R @@ -67,7 +67,6 @@ test_that( test_that( desc = "subtitle output", code = { - # should output a list of length 3 set.seed(123) p_sub <- gghistostats( data = ggplot2::msleep, diff --git a/tests/testthat/test-ggwithinstats.R b/tests/testthat/test-ggwithinstats.R index d9c34fe0f..9490568a7 100644 --- a/tests/testthat/test-ggwithinstats.R +++ b/tests/testthat/test-ggwithinstats.R @@ -2,6 +2,7 @@ skip_if_not_installed("PMCMRplus") skip_if_not_installed("afex") skip_if_not_installed("WRS2") +skip_if_not_installed("rstantools") data_bugs_2 <- dplyr::filter(bugs_long, subject <= 30L, condition %in% c("HDLF", "HDHF")) @@ -17,7 +18,7 @@ test_that( data = data_bugs_2, x = condition, y = desire, - pairwise.comparisons = FALSE, + pairwise.display = "none", ggsignif.args = list(textsize = 6, tip_length = 0.01), point.path.args = list(color = "red"), centrality.path.args = list(color = "blue", size = 2, alpha = 0.8), @@ -33,7 +34,7 @@ test_that( data = WRS2::WineTasting, x = Wine, y = Taste, - pairwise.comparisons = FALSE, + pairwise.display = "none", title = "wine tasting data" ) ) @@ -53,7 +54,7 @@ test_that( x = Wine, y = Taste, results.subtitle = FALSE, - pairwise.comparisons = FALSE, + pairwise.display = "none", ggplot.component = ggplot2::labs(y = "Taste rating") ) ) @@ -68,7 +69,7 @@ test_that( centrality.point.args = list(size = 5, alpha = 0.5, color = "darkred"), centrality.path = FALSE, results.subtitle = FALSE, - pairwise.comparisons = FALSE + pairwise.display = "none" ) ) } diff --git a/vignettes/web_only/faq.Rmd b/vignettes/web_only/faq.Rmd index 042862e01..3bbf20a38 100644 --- a/vignettes/web_only/faq.Rmd +++ b/vignettes/web_only/faq.Rmd @@ -294,8 +294,7 @@ Here is a workaround using `{ggsignif}`: library(ggsignif) -## displaying only one comparison -ggbetweenstats(mtcars, cyl, wt, pairwise.comparisons = FALSE) + +ggbetweenstats(mtcars, cyl, wt, pairwise.display = "none") + geom_signif(comparisons = list(c("4", "6")), test.args = list(exact = FALSE)) ``` @@ -329,7 +328,7 @@ library(ggsignif) mtcars$cyl <- as.factor(mtcars$cyl) # creating the base plot -p <- ggbetweenstats(mtcars, cyl, wt, pairwise.comparisons = FALSE) +p <- ggbetweenstats(mtcars, cyl, wt, pairwise.display = "none") # using `pairwise_comparisons()` function to create a data frame with results df <- pairwise_comparisons(mtcars, cyl, wt) %>% @@ -385,7 +384,7 @@ ggwithinstats( x = condition, y = desire, results.subtitle = FALSE, - pairwise.comparisons = FALSE + pairwise.display = "none" ) # after @@ -395,7 +394,7 @@ ggwithinstats( y = desire, point.args = list(alpha = 0), results.subtitle = FALSE, - pairwise.comparisons = FALSE + pairwise.display = "none" ) ``` @@ -445,7 +444,7 @@ grouped_ggbetweenstats( wt, grouping.var = am, results.subtitle = FALSE, - pairwise.comparisons = FALSE, + pairwise.display = "none", # modify further with `{ggplot2}` functions ggplot.component = list( scale_color_manual(values = paletteer::paletteer_c("viridis::viridis", 3)), @@ -624,6 +623,17 @@ The following `README` file briefly describes the installation procedure: For MacOS, have a look at this [post](https://stackoverflow.com/questions/35360885/installing-finding-gmp-under-osx). +## 28. How to modify the secondary Y-axis title? + +```{r} +ggbetweenstats( + mtcars, cyl, wt, + ggplot.component = list( + ggplot2::scale_y_continuous(sec.axis = ggplot2::dup_axis(name = "My custom test")) + ) +) +``` + ## Suggestions If you find any bugs or have any suggestions/remarks, please file an issue on diff --git a/vignettes/web_only/ggbarstats.Rmd b/vignettes/web_only/ggbarstats.Rmd index 4d4799bfc..ef966c11f 100644 --- a/vignettes/web_only/ggbarstats.Rmd +++ b/vignettes/web_only/ggbarstats.Rmd @@ -194,7 +194,7 @@ unique combination of `Boat` and `Month`. #| fig.height = 8, #| fig.width = 9 -# creating a data frame + # (this is completely fictional; I don't know first thing about fishing!) ( fishing <- tibble::as_tibble(data.frame( diff --git a/vignettes/web_only/ggpiestats.Rmd b/vignettes/web_only/ggpiestats.Rmd index 0f0fe34d4..98dc0ce25 100644 --- a/vignettes/web_only/ggpiestats.Rmd +++ b/vignettes/web_only/ggpiestats.Rmd @@ -207,7 +207,7 @@ unique combination of `Boat` and `Month`. #| fig.height = 8, #| fig.width = 9 -# creating a data frame + # (this is completely fictional; I don't know first thing about fishing!) ( fishing <- tibble::as_tibble(data.frame( diff --git a/vignettes/web_only/ggwithinstats.Rmd b/vignettes/web_only/ggwithinstats.Rmd index d7ac8ccc3..a06a1823f 100644 --- a/vignettes/web_only/ggwithinstats.Rmd +++ b/vignettes/web_only/ggwithinstats.Rmd @@ -135,11 +135,6 @@ ggwithinstats( type = "nonparametric", ## type of statistical test xlab = "Condition", ## label for the x-axis ylab = "Desire to kill an artrhopod", ## label for the y-axis - effsize.type = "biased", ## type of effect size - sphericity.correction = FALSE, ## don't display sphericity corrected dfs and p-values - pairwise.comparisons = TRUE, ## display pairwise comparisons - mean.plotting = TRUE, ## whether the mean is to be displayed - mean.color = "darkblue", ## color for mean package = "yarrr", ## package from which color palette is to be taken palette = "info2", ## choosing a different color palette title = "Comparison of desire to kill bugs",