Skip to content

Commit

Permalink
Rename k parameter to digits and crosstabs defaults to two-sided …
Browse files Browse the repository at this point in the history
…alternative hypothesis (#918)

* No need to run examples conditional on availability of PMCMRplus

* update meta data as well

* rename `k` parameter to `digits`

* Apply automatic changes

* Update WORDLIST

* ggpie and ggbar default to two-sided alternative

* use devel-statsExpressions

---------

Co-authored-by: IndrajeetPatil <[email protected]>
  • Loading branch information
IndrajeetPatil and IndrajeetPatil authored Mar 17, 2024
1 parent 50bb5ed commit 7649557
Show file tree
Hide file tree
Showing 66 changed files with 386 additions and 355 deletions.
18 changes: 9 additions & 9 deletions API
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ combine_plots(plotlist, plotgrid.args = list(), annotation.args = list(), guides
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"), sample.size.label.args = list(size = 4), 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.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, na.rm = TRUE), 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.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, ...)
ggbarstats(data, x, y, counts = NULL, type = "parametric", paired = FALSE, results.subtitle = TRUE, label = "percentage", label.args = list(alpha = 1, fill = "white"), sample.size.label.args = list(size = 4), digits = 2L, proportion.test = results.subtitle, digits.perc = 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.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, digits = 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, digits = 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, na.rm = TRUE), 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, digits = 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, digits = 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, digits = 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, digits = 2L, proportion.test = results.subtitle, digits.perc = 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, digits = 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.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, digits = 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())
Expand Down
41 changes: 13 additions & 28 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -----------------------------------------------------------
# CITATION file created with {cffr} R package, v0.5.0
# CITATION file created with {cffr} R package, v1.0.0
# See also: https://docs.ropensci.org/cffr/
# -----------------------------------------------------------

Expand All @@ -17,7 +17,7 @@ abstract: 'Extension of ''ggplot2'', ''ggstatsplot'' creates graphics with detai
(pie and bar charts) data. Currently, it supports the most common types of statistical
approaches and tests: parametric, nonparametric, robust, and Bayesian versions of
t-test/ANOVA, correlation analyses, contingency table analysis, meta-analysis, and
regression analyses. References: Patil (2021) <doi:10.21105/joss.03236>.'
regression analyses. References: Patil (2021) <https://doi.org/10.21105/joss.03236>.'
authors:
- family-names: Patil
given-names: Indrajeet
Expand Down Expand Up @@ -66,11 +66,10 @@ references:
url: https://www.R-project.org/
authors:
- name: R Core Team
location:
name: Vienna, Austria
year: '2024'
institution:
name: R Foundation for Statistical Computing
address: Vienna, Austria
year: '2024'
version: '>= 4.1.0'
- type: software
title: correlation
Expand Down Expand Up @@ -209,8 +208,9 @@ references:
- family-names: Dunnington
given-names: Dewey
orcid: https://orcid.org/0000-0002-9415-4582
- family-names: van den Brand
- family-names: Brand
given-names: Teun
name-particle: van den
orcid: https://orcid.org/0000-0002-9335-7468
year: '2024'
version: '>= 3.5.0'
Expand Down Expand Up @@ -277,7 +277,7 @@ references:
abstract: 'insight: Easy Access to Model Information for Various Model Objects'
notes: Imports
url: https://easystats.github.io/insight/
repository: https://easystats.r-universe.dev
repository: https://CRAN.R-project.org/package=insight
authors:
- family-names: Lüdecke
given-names: Daniel
Expand Down Expand Up @@ -442,11 +442,10 @@ references:
notes: Imports
authors:
- name: R Core Team
location:
name: Vienna, Austria
year: '2024'
institution:
name: R Foundation for Statistical Computing
address: Vienna, Austria
year: '2024'
- type: software
title: statsExpressions
abstract: 'statsExpressions: Tidy Dataframes and Expressions with Statistical Details'
Expand All @@ -458,7 +457,7 @@ references:
given-names: Indrajeet
email: [email protected]
orcid: https://orcid.org/0000-0003-1995-6531
version: '>= 1.5.3'
version: '>= 1.5.3.9000'
year: '2024'
- type: software
title: tidyr
Expand All @@ -483,11 +482,10 @@ references:
notes: Imports
authors:
- name: R Core Team
location:
name: Vienna, Austria
year: '2024'
institution:
name: R Foundation for Statistical Computing
address: Vienna, Austria
year: '2024'
- type: software
title: afex
abstract: 'afex: Analysis of Factorial Experiments'
Expand Down Expand Up @@ -523,7 +521,7 @@ references:
given-names: Jeffrey N.
email: [email protected]
year: '2024'
version: '>= 0.9.12-4.5'
version: '>= 0.9.12-4.7'
- type: software
title: gapminder
abstract: 'gapminder: Data from Gapminder'
Expand Down Expand Up @@ -619,19 +617,6 @@ references:
email: [email protected]
- name: R Development Core Team
year: '2024'
- type: software
title: PMCMRplus
abstract: 'PMCMRplus: Calculate Pairwise Multiple Comparisons of Mean Rank Sums
Extended'
notes: Suggests
repository: https://CRAN.R-project.org/package=PMCMRplus
authors:
- family-names: Pohlert
given-names: Thorsten
email: [email protected]
orcid: https://orcid.org/0000-0003-3855-3025
year: '2024'
version: '>= 1.9.10'
- type: software
title: psych
abstract: 'psych: Procedures for Psychological, Psychometric, and Personality Research'
Expand Down
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,19 @@ Imports:
purrr (>= 1.0.2),
rlang,
stats,
statsExpressions (>= 1.5.3),
statsExpressions (>= 1.5.3.9000),
tidyr (>= 1.3.0),
utils
Suggests:
afex,
BayesFactor (>= 0.9.12-4.5),
BayesFactor (>= 0.9.12-4.7),
gapminder,
knitr,
lme4 (>= 1.1-35.1),
MASS,
metaBMA,
metafor,
metaplus,
PMCMRplus (>= 1.9.10),
psych,
rmarkdown,
rstantools,
Expand All @@ -72,6 +71,7 @@ Suggests:
withr,
WRS2
Remotes:
IndrajeetPatil/statsExpressions,
tidyverse/ggplot2
VignetteBuilder:
knitr
Expand Down
10 changes: 9 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ N.B. All statistical analysis in `{ggstatsplot}` is carried out in
read the `NEWS` for that package:
<https://indrajeetpatil.github.io/statsExpressions/news/index.html>

## MAJOR CHANGES

- The cryptic but very useful parameter `k` has been renamed to `digits` to
improve its discoverability.

- To be consistent with other functions, `ggpiestats()` and `ggbarstats()` now
default to two-sided alternative hypothesis.

# ggstatsplot 0.12.2

- No user-visible changes. Maintenance-only release.
Expand Down Expand Up @@ -1386,7 +1394,7 @@ This uncoupling is designed to achieve two things:
omega-squared effect sizes for anovas, in addition to the prior partial
variants of these effect sizes.

- `ggpiestats` gains `perc.k` argument to show desired number of decimal
- `ggpiestats` gains `digits.perc` argument to show desired number of decimal
places in percentage labels.

## BUG FIXES
Expand Down
2 changes: 1 addition & 1 deletion R/extract-stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#'
#' @autoglobal
#'
#' @examplesIf identical(Sys.getenv("NOT_CRAN"), "true") && requireNamespace("PMCMRplus", quietly = TRUE)
#' @examplesIf identical(Sys.getenv("NOT_CRAN"), "true")
#' set.seed(123)
#'
#' # non-grouped plot
Expand Down
26 changes: 13 additions & 13 deletions R/ggbarstats.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ ggbarstats <- function(
label = "percentage",
label.args = list(alpha = 1.0, fill = "white"),
sample.size.label.args = list(size = 4.0),
k = 2L,
digits = 2L,
proportion.test = results.subtitle,
perc.k = 0L,
digits.perc = 0L,
bf.message = TRUE,
ratio = NULL,
conf.level = 0.95,
Expand Down Expand Up @@ -94,15 +94,15 @@ ggbarstats <- function(

if (results.subtitle) {
.f.args <- list(
data = data,
x = {{ x }},
y = {{ y }},
conf.level = conf.level,
k = k,
paired = paired,
ratio = ratio,
sampling.plan = sampling.plan,
fixed.margin = fixed.margin,
data = data,
x = {{ x }},
y = {{ y }},
conf.level = conf.level,
digits = digits,
paired = paired,
ratio = ratio,
sampling.plan = sampling.plan,
fixed.margin = fixed.margin,
prior.concentration = prior.concentration
)

Expand All @@ -119,10 +119,10 @@ ggbarstats <- function(
# plot ------------------------------------------

# data frame with summary labels
descriptive_df <- descriptive_data(data, {{ x }}, {{ y }}, label, perc.k)
descriptive_df <- descriptive_data(data, {{ x }}, {{ y }}, label, digits.perc)

# data frame containing all details needed for prop test
onesample_df <- onesample_data(data, {{ x }}, {{ y }}, k)
onesample_df <- onesample_data(data, {{ x }}, {{ y }}, digits)

# if no. of factor levels is greater than the default palette color count
.is_palette_sufficient(package, palette, nlevels(pull(data, {{ x }})))
Expand Down
Loading

0 comments on commit 7649557

Please sign in to comment.