Skip to content

Commit

Permalink
rename k parameter to digits
Browse files Browse the repository at this point in the history
  • Loading branch information
IndrajeetPatil committed Mar 17, 2024
1 parent b60a5fe commit 66d0376
Show file tree
Hide file tree
Showing 44 changed files with 337 additions and 250 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
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Imports:
purrr (>= 1.0.2),
rlang,
stats,
statsExpressions (>= 1.5.3),
statsExpressions (>= 1.5.3.9000),
tidyr (>= 1.3.0),
utils
Suggests:
Expand All @@ -71,6 +71,7 @@ Suggests:
withr,
WRS2
Remotes:
IndrajeetPatil/statsExpressions@rename-k-parameter,
tidyverse/ggplot2
VignetteBuilder:
knitr
Expand Down
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ 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.

# ggstatsplot 0.12.2

- No user-visible changes. Maintenance-only release.
Expand Down Expand Up @@ -1386,7 +1390,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
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
52 changes: 26 additions & 26 deletions R/ggbetweenstats.R
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ ggbetweenstats <- function(
caption = NULL,
title = NULL,
subtitle = NULL,
k = 2L,
digits = 2L,
var.equal = FALSE,
conf.level = 0.95,
nboot = 100L,
Expand Down Expand Up @@ -203,17 +203,17 @@ ggbetweenstats <- function(

if (results.subtitle) {
.f.args <- list(
data = data,
x = as_string(x),
y = as_string(y),
data = data,
x = as_string(x),
y = as_string(y),
effsize.type = effsize.type,
conf.level = conf.level,
var.equal = var.equal,
k = k,
tr = tr,
paired = FALSE,
bf.prior = bf.prior,
nboot = nboot
conf.level = conf.level,
var.equal = var.equal,
digits = digits,
tr = tr,
paired = FALSE,
bf.prior = bf.prior,
nboot = nboot
)

.f <- .f_switch(test)
Expand All @@ -237,13 +237,13 @@ ggbetweenstats <- function(

if (isTRUE(centrality.plotting)) {
plot_comparison <- suppressWarnings(.centrality_ggrepel(
plot = plot_comparison,
data = data,
x = {{ x }},
y = {{ y }},
k = k,
type = stats_type_switch(centrality.type),
tr = tr,
plot = plot_comparison,
data = data,
x = {{ x }},
y = {{ y }},
digits = digits,
type = stats_type_switch(centrality.type),
tr = tr,
centrality.point.args = centrality.point.args,
centrality.label.args = centrality.label.args
))
Expand All @@ -255,15 +255,15 @@ ggbetweenstats <- function(

if (pairwise.display != "none" && test == "anova") {
mpc_df <- pairwise_comparisons(
data = data,
x = {{ x }},
y = {{ y }},
type = type,
tr = tr,
paired = FALSE,
var.equal = var.equal,
data = data,
x = {{ x }},
y = {{ y }},
type = type,
tr = tr,
paired = FALSE,
var.equal = var.equal,
p.adjust.method = p.adjust.method,
k = k
digits = digits,
)

Check warning on line 267 in R/ggbetweenstats.R

View workflow job for this annotation

GitHub Actions / lint

file=R/ggbetweenstats.R,line=267,col=5,[missing_argument_linter] Missing argument 10 in function call.

Check warning on line 267 in R/ggbetweenstats.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/ggbetweenstats.R,line=267,col=5,[missing_argument_linter] Missing argument 10 in function call.

# adding the layer for pairwise comparisons
Expand Down
8 changes: 4 additions & 4 deletions R/ggcoefstats.R
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ ggcoefstats <- function(
statistic = NULL,
conf.int = TRUE,
conf.level = 0.95,
k = 2L,
digits = 2L,
exclude.intercept = FALSE,
effectsize.type = "eta",
meta.analytic.effect = FALSE,
Expand Down Expand Up @@ -218,7 +218,7 @@ ggcoefstats <- function(
# label -------------------------

if (stats.labels) {
tidy_df %<>% tidy_model_expressions(statistic, k, effectsize.type)
tidy_df %<>% tidy_model_expressions(statistic, digits, effectsize.type)

# only significant p-value labels are shown
if (only.significant && ("p.value" %in% names(tidy_df))) {
Expand Down Expand Up @@ -249,12 +249,12 @@ ggcoefstats <- function(
meta.type <- stats_type_switch(meta.type)

# frequentist
subtitle_df <- meta_analysis(tidy_df, type = meta.type, k = k)
subtitle_df <- meta_analysis(tidy_df, type = meta.type, digits = digits)
subtitle <- .extract_expression(subtitle_df)

# Bayesian
if (meta.type == "parametric" && bf.message) {
caption_df <- suppressWarnings(meta_analysis(tidy_df, type = "bayes", k = k))
caption_df <- suppressWarnings(meta_analysis(tidy_df, type = "bayes", digits = digits))
caption <- .extract_expression(caption_df)
}
}
Expand Down
4 changes: 2 additions & 2 deletions R/ggcorrmat.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ ggcorrmat <- function(
type = "parametric",
tr = 0.2,
partial = FALSE,
k = 2L,
digits = 2L,
sig.level = 0.05,
conf.level = 0.95,
bf.prior = 0.707,
Expand Down Expand Up @@ -138,7 +138,7 @@ ggcorrmat <- function(
lab = TRUE,
pch = pch,
legend.title = legend.title,
digits = k,
digits = digits,
!!!ggcorrplot.args
)

Expand Down
Loading

0 comments on commit 66d0376

Please sign in to comment.