diff --git a/API b/API index b40ce4846..73ebec6a6 100644 --- a/API +++ b/API @@ -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()) diff --git a/DESCRIPTION b/DESCRIPTION index 945c8b111..68f6a61be 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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: @@ -71,6 +71,7 @@ Suggests: withr, WRS2 Remotes: + IndrajeetPatil/statsExpressions@rename-k-parameter, tidyverse/ggplot2 VignetteBuilder: knitr diff --git a/NEWS.md b/NEWS.md index 42bb35d61..7f1cffb0d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,10 @@ N.B. All statistical analysis in `{ggstatsplot}` is carried out in read the `NEWS` for that package: +## 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. @@ -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 diff --git a/R/ggbarstats.R b/R/ggbarstats.R index bc58c5838..481ccbd28 100644 --- a/R/ggbarstats.R +++ b/R/ggbarstats.R @@ -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, @@ -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 ) @@ -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 }}))) diff --git a/R/ggbetweenstats.R b/R/ggbetweenstats.R index d1349d023..abd7927b3 100644 --- a/R/ggbetweenstats.R +++ b/R/ggbetweenstats.R @@ -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, @@ -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) @@ -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 )) @@ -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, ) # adding the layer for pairwise comparisons diff --git a/R/ggcoefstats.R b/R/ggcoefstats.R index 7e03b7e8b..027ca8c69 100644 --- a/R/ggcoefstats.R +++ b/R/ggcoefstats.R @@ -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, @@ -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))) { @@ -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) } } diff --git a/R/ggcorrmat.R b/R/ggcorrmat.R index 214a361eb..d581a7d1a 100644 --- a/R/ggcorrmat.R +++ b/R/ggcorrmat.R @@ -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, @@ -138,7 +138,7 @@ ggcorrmat <- function( lab = TRUE, pch = pch, legend.title = legend.title, - digits = k, + digits = digits, !!!ggcorrplot.args ) diff --git a/R/ggdotplotstats.R b/R/ggdotplotstats.R index 464054f3f..a8f585278 100644 --- a/R/ggdotplotstats.R +++ b/R/ggdotplotstats.R @@ -63,7 +63,7 @@ ggdotplotstats <- function( effsize.type = "g", conf.level = 0.95, tr = 0.2, - k = 2L, + digits = 2L, results.subtitle = TRUE, point.args = list(color = "black", size = 3, shape = 16), centrality.plotting = TRUE, @@ -96,14 +96,14 @@ ggdotplotstats <- function( if (results.subtitle) { .f.args <- list( - data = data, - x = {{ x }}, - test.value = test.value, + data = data, + x = {{ x }}, + test.value = test.value, effsize.type = effsize.type, - conf.level = conf.level, - k = k, - tr = tr, - bf.prior = bf.prior + conf.level = conf.level, + digits = digits, + tr = tr, + bf.prior = bf.prior ) subtitle_df <- .eval_f(one_sample_test, !!!.f.args, type = type) @@ -135,10 +135,10 @@ ggdotplotstats <- function( if (isTRUE(centrality.plotting)) { plot_dot <- .histo_labeller( plot_dot, - x = pull(data, {{ x }}), - type = stats_type_switch(centrality.type), - tr = tr, - k = k, + x = pull(data, {{ x }}), + type = stats_type_switch(centrality.type), + tr = tr, + digits = digits, centrality.line.args = centrality.line.args ) } diff --git a/R/gghistostats.R b/R/gghistostats.R index c9e20c2e0..24c4c5a12 100644 --- a/R/gghistostats.R +++ b/R/gghistostats.R @@ -73,7 +73,7 @@ gghistostats <- function( effsize.type = "g", conf.level = 0.95, tr = 0.2, - k = 2L, + digits = 2L, ggtheme = ggstatsplot::theme_ggstatsplot(), results.subtitle = TRUE, bin.args = list(color = "black", fill = "grey50", alpha = 0.7), @@ -96,14 +96,14 @@ gghistostats <- function( type <- stats_type_switch(type) .f.args <- list( - data = data, - x = {{ x }}, - test.value = test.value, + data = data, + x = {{ x }}, + test.value = test.value, effsize.type = effsize.type, - conf.level = conf.level, - k = k, - tr = tr, - bf.prior = bf.prior + conf.level = conf.level, + digits = digits, + tr = tr, + bf.prior = bf.prior ) # subtitle with statistical results @@ -151,10 +151,10 @@ gghistostats <- function( if (isTRUE(centrality.plotting)) { plot_hist <- .histo_labeller( plot_hist, - x = x_vec, - type = stats_type_switch(centrality.type), - tr = tr, - k = k, + x = x_vec, + type = stats_type_switch(centrality.type), + tr = tr, + digits = digits, centrality.line.args = centrality.line.args ) } diff --git a/R/ggpiestats-ggbarstats-helpers.R b/R/ggpiestats-ggbarstats-helpers.R index f9249e7c6..9053838c9 100644 --- a/R/ggpiestats-ggbarstats-helpers.R +++ b/R/ggpiestats-ggbarstats-helpers.R @@ -6,14 +6,14 @@ descriptive_data <- function( x, y = NULL, label.content = "percentage", - perc.k = 1L, + digits.perc = 1L, ...) { .cat_counter(data, {{ x }}, {{ y }}) %>% mutate( .label = case_when( - grepl("perc|prop", label.content) ~ paste0(round(perc, perc.k), "%"), + grepl("perc|prop", label.content) ~ paste0(round(perc, digits.perc), "%"), grepl("count|n|N", label.content) ~ .prettyNum(counts), - .default = paste0(.prettyNum(counts), "\n", "(", round(perc, perc.k), "%)") + .default = paste0(.prettyNum(counts), "\n", "(", round(perc, digits.perc), "%)") ), # reorder the category factor levels to order the legend {{ x }} := factor({{ x }}, unique({{ x }})) ) @@ -36,7 +36,7 @@ descriptive_data <- function( #' @title A data frame with chi-squared test results #' @autoglobal #' @noRd -onesample_data <- function(data, x, y, k = 2L, ...) { +onesample_data <- function(data, x, y, digits = 2L, ...) { full_join( # descriptive summary x = .cat_counter(data, {{ y }}) %>% @@ -49,8 +49,8 @@ onesample_data <- function(data, x, y, k = 2L, ...) { ) %>% rowwise() %>% mutate( - .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)}')") + .label = glue("list(~chi['gof']^2~({df})=={format_value(statistic, digits)}, ~italic(p)=='{format_value(p.value, digits)}', ~italic(n)=='{.prettyNum(counts)}')"), + .p.label = glue("list(~italic(p)=='{format_value(p.value, digits)}')") ) %>% ungroup() } diff --git a/R/ggpiestats.R b/R/ggpiestats.R index c9102232b..fb8e1de4e 100644 --- a/R/ggpiestats.R +++ b/R/ggpiestats.R @@ -22,7 +22,7 @@ #' @param proportion.test Decides whether proportion test for `x` variable is to #' be carried out for each level of `y`. Defaults to `results.subtitle`. In #' `ggbarstats`, only *p*-values from this test will be displayed. -#' @param perc.k Numeric that decides number of decimal places for percentage +#' @param digits.perc Numeric that decides number of decimal places for percentage #' labels (Default: `0L`). #' @param label Character decides what information needs to be displayed #' on the label in each pie slice. Possible options are `"percentage"` @@ -74,9 +74,9 @@ ggpiestats <- function( label = "percentage", label.args = list(direction = "both"), label.repel = FALSE, - k = 2L, + digits = 2L, proportion.test = results.subtitle, - perc.k = 0L, + digits.perc = 0L, bf.message = TRUE, ratio = NULL, conf.level = 0.95, @@ -126,15 +126,15 @@ ggpiestats <- 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 ) @@ -151,10 +151,10 @@ ggpiestats <- 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 proportion test - if (test == "two.way") onesample_df <- onesample_data(data, {{ x }}, {{ y }}, k) + if (test == "two.way") 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, min_length = x_levels) diff --git a/R/ggscatterstats.R b/R/ggscatterstats.R index abc8b8c5a..03dd2d8a3 100644 --- a/R/ggscatterstats.R +++ b/R/ggscatterstats.R @@ -86,7 +86,7 @@ ggscatterstats <- function( bf.prior = 0.707, bf.message = TRUE, tr = 0.2, - k = 2L, + digits = 2L, results.subtitle = TRUE, label.var = NULL, label.expression = NULL, @@ -119,13 +119,12 @@ ggscatterstats <- function( if (results.subtitle) { type <- stats_type_switch(type) - .f.args <- list( data = data, x = {{ x }}, y = {{ y }}, conf.level = conf.level, - k = k, + digits = digits, tr = tr, bf.prior = bf.prior ) diff --git a/R/ggwithinstats.R b/R/ggwithinstats.R index 00f582b77..5a919ecf4 100644 --- a/R/ggwithinstats.R +++ b/R/ggwithinstats.R @@ -94,7 +94,7 @@ ggwithinstats <- function( caption = NULL, title = NULL, subtitle = NULL, - k = 2L, + digits = 2L, conf.level = 0.95, nboot = 100L, tr = 0.2, @@ -136,16 +136,16 @@ ggwithinstats <- 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, - k = k, - tr = tr, - paired = TRUE, - bf.prior = bf.prior, - nboot = nboot + conf.level = conf.level, + digits = digits, + tr = tr, + paired = TRUE, + bf.prior = bf.prior, + nboot = nboot ) # styler: off @@ -176,15 +176,15 @@ ggwithinstats <- 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, - centrality.path = centrality.path, - centrality.path.args = centrality.path.args, + plot = plot_comparison, + data = data, + x = {{ x }}, + y = {{ y }}, + digits = digits, + type = stats_type_switch(centrality.type), + tr = tr, + centrality.path = centrality.path, + centrality.path.args = centrality.path.args, centrality.point.args = centrality.point.args, centrality.label.args = centrality.label.args )) @@ -197,14 +197,14 @@ ggwithinstats <- function( if (pairwise.display != "none" && test == "anova") { mpc_df <- pairwise_comparisons( - data = data, - x = {{ x }}, - y = {{ y }}, - type = type, - tr = tr, - paired = TRUE, + data = data, + x = {{ x }}, + y = {{ y }}, + type = type, + tr = tr, + paired = TRUE, p.adjust.method = p.adjust.method, - k = k + digits = digits, ) # adding the layer for pairwise comparisons diff --git a/WIP/ggridgestats.R b/WIP/ggridgestats.R index 3279dae3d..d10adab23 100644 --- a/WIP/ggridgestats.R +++ b/WIP/ggridgestats.R @@ -30,7 +30,7 @@ ggridgestats <- function(data, caption = NULL, title = NULL, subtitle = NULL, - k = 2L, + digits = 2L, var.equal = FALSE, conf.level = 0.95, nboot = 100L, @@ -59,13 +59,13 @@ ggridgestats <- function(data, ...) { # data ----------------------------------- - + 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)) - + data %<>% dplyr::select({{ x }}, {{ y }}) %>% tidyr::drop_na() %>% @@ -77,7 +77,7 @@ ggridgestats <- function(data, test <- ifelse(nlevels(data %>% dplyr::pull({{ x }})) < 3, "t", "anova") if (results.subtitle) { - + .f.args <- list( data = data, x = rlang::as_string(x), @@ -86,7 +86,7 @@ ggridgestats <- function(data, effsize.type = effsize.type, conf.level = conf.level, var.equal = var.equal, - k = k, + digits = digits, tr = tr, bf.prior = bf.prior, nboot = nboot @@ -111,7 +111,7 @@ ggridgestats <- function(data, y = {{ y }}, type = type, tr = tr, - k = k + digits = digits ) @@ -174,7 +174,7 @@ ggridgestats <- function(data, paired = paired, var.equal = var.equal, p.adjust.method = p.adjust.method, - k = k + digits = digits ) # adding the layer for pairwise comparisons diff --git a/man/ggbarstats.Rd b/man/ggbarstats.Rd index 41e0a20bc..58a61ddf2 100644 --- a/man/ggbarstats.Rd +++ b/man/ggbarstats.Rd @@ -15,9 +15,9 @@ ggbarstats( label = "percentage", label.args = list(alpha = 1, fill = "white"), sample.size.label.args = list(size = 4), - k = 2L, + digits = 2L, proportion.test = results.subtitle, - perc.k = 0L, + digits.perc = 0L, bf.message = TRUE, ratio = NULL, conf.level = 0.95, @@ -68,9 +68,7 @@ represents a single observation.} You can specify just the initial letter.} \item{paired}{Logical indicating whether data came from a within-subjects or -repeated measures design study (Default: \code{FALSE}). If \code{TRUE}, McNemar's -test expression will be returned. If \code{FALSE}, Pearson's chi-square test will -be returned.} +repeated measures design study (Default: \code{FALSE}).} \item{results.subtitle}{Decides whether the results of statistical tests are to be displayed as a subtitle (Default: \code{TRUE}). If set to \code{FALSE}, only @@ -86,14 +84,18 @@ on the label in each pie slice. Possible options are \code{"percentage"} \item{sample.size.label.args}{Additional aesthetic arguments that will be passed to \code{ggplot2::geom_text()}.} -\item{k}{Number of digits after decimal point (should be an integer) -(Default: \code{k = 2L}).} +\item{digits}{Number of digits for rounding or significant figures. May also +be \code{"signif"} to return significant figures or \code{"scientific"} +to return scientific notation. Control the number of digits by adding the +value as suffix, e.g. \code{digits = "scientific4"} to have scientific +notation with 4 decimal places, or \code{digits = "signif5"} for 5 +significant figures (see also \code{\link[=signif]{signif()}}).} \item{proportion.test}{Decides whether proportion test for \code{x} variable is to be carried out for each level of \code{y}. Defaults to \code{results.subtitle}. In \code{ggbarstats}, only \emph{p}-values from this test will be displayed.} -\item{perc.k}{Numeric that decides number of decimal places for percentage +\item{digits.perc}{Numeric that decides number of decimal places for percentage labels (Default: \code{0L}).} \item{bf.message}{Logical that decides whether to display Bayes Factor in @@ -101,10 +103,10 @@ favor of the \emph{null} hypothesis. This argument is relevant only \strong{for parametric test} (Default: \code{TRUE}).} \item{ratio}{A vector of proportions: the expected proportions for the -proportion test (should sum to 1). Default is \code{NULL}, which means the null +proportion test (should sum to \code{1}). Default is \code{NULL}, which means the null is equal theoretical proportions across the levels of the nominal variable. -This means if there are two levels this will be \code{ratio = c(0.5,0.5)} or if -there are four levels this will be \code{ratio = c(0.25,0.25,0.25,0.25)}, etc.} +E.g., \code{ratio = c(0.5, 0.5)} for two levels, +\code{ratio = c(0.25, 0.25, 0.25, 0.25)} for four levels, etc.} \item{conf.level}{Scalar between \code{0} and \code{1} (default: \verb{95\%} confidence/credible intervals, \code{0.95}). If \code{NULL}, no confidence intervals diff --git a/man/ggbetweenstats.Rd b/man/ggbetweenstats.Rd index 6afac89c8..7bb205153 100644 --- a/man/ggbetweenstats.Rd +++ b/man/ggbetweenstats.Rd @@ -20,7 +20,7 @@ ggbetweenstats( caption = NULL, title = NULL, subtitle = NULL, - k = 2L, + digits = 2L, var.equal = FALSE, conf.level = 0.95, nboot = 100L, @@ -119,8 +119,12 @@ if \code{bf.message = FALSE}.} \item{subtitle}{The text for the plot subtitle. Will work only if \code{results.subtitle = FALSE}.} -\item{k}{Number of digits after decimal point (should be an integer) -(Default: \code{k = 2L}).} +\item{digits}{Number of digits for rounding or significant figures. May also +be \code{"signif"} to return significant figures or \code{"scientific"} +to return scientific notation. Control the number of digits by adding the +value as suffix, e.g. \code{digits = "scientific4"} to have scientific +notation with 4 decimal places, or \code{digits = "signif5"} for 5 +significant figures (see also \code{\link[=signif]{signif()}}).} \item{var.equal}{a logical variable indicating whether to treat the two variances as being equal. If \code{TRUE} then the pooled diff --git a/man/ggcoefstats.Rd b/man/ggcoefstats.Rd index 19fb50ae5..f53b8def8 100644 --- a/man/ggcoefstats.Rd +++ b/man/ggcoefstats.Rd @@ -9,7 +9,7 @@ ggcoefstats( statistic = NULL, conf.int = TRUE, conf.level = 0.95, - k = 2L, + digits = 2L, exclude.intercept = FALSE, effectsize.type = "eta", meta.analytic.effect = FALSE, @@ -52,8 +52,12 @@ error bars (Default: \code{TRUE}).} \item{conf.level}{Numeric deciding level of confidence or credible intervals (Default: \code{0.95}).} -\item{k}{Number of digits after decimal point (should be an integer) -(Default: \code{k = 2L}).} +\item{digits}{Number of digits for rounding or significant figures. May also +be \code{"signif"} to return significant figures or \code{"scientific"} +to return scientific notation. Control the number of digits by adding the +value as suffix, e.g. \code{digits = "scientific4"} to have scientific +notation with 4 decimal places, or \code{digits = "signif5"} for 5 +significant figures (see also \code{\link[=signif]{signif()}}).} \item{exclude.intercept}{Logical that decides whether the intercept should be excluded from the plot (Default: \code{FALSE}).} diff --git a/man/ggcorrmat.Rd b/man/ggcorrmat.Rd index 2a6a3b521..9fd4205cf 100644 --- a/man/ggcorrmat.Rd +++ b/man/ggcorrmat.Rd @@ -12,7 +12,7 @@ ggcorrmat( type = "parametric", tr = 0.2, partial = FALSE, - k = 2L, + digits = 2L, sig.level = 0.05, conf.level = 0.95, bf.prior = 0.707, @@ -61,8 +61,12 @@ of an error, try reducing the value of \code{tr}, which is by default set to correlations, "full" instead of pseudo-Bayesian partial correlations (i.e., Bayesian correlation based on frequentist partialization) are returned.} -\item{k}{Number of digits after decimal point (should be an integer) -(Default: \code{k = 2L}).} +\item{digits}{Number of digits for rounding or significant figures. May also +be \code{"signif"} to return significant figures or \code{"scientific"} +to return scientific notation. Control the number of digits by adding the +value as suffix, e.g. \code{digits = "scientific4"} to have scientific +notation with 4 decimal places, or \code{digits = "signif5"} for 5 +significant figures (see also \code{\link[=signif]{signif()}}).} \item{sig.level}{Significance level (Default: \code{0.05}). If the \emph{p}-value in \emph{p}-value matrix is bigger than \code{sig.level}, then the corresponding diff --git a/man/ggdotplotstats.Rd b/man/ggdotplotstats.Rd index e081cc61a..0ded5ab25 100644 --- a/man/ggdotplotstats.Rd +++ b/man/ggdotplotstats.Rd @@ -20,7 +20,7 @@ ggdotplotstats( effsize.type = "g", conf.level = 0.95, tr = 0.2, - k = 2L, + digits = 2L, results.subtitle = TRUE, point.args = list(color = "black", size = 3, shape = 16), centrality.plotting = TRUE, @@ -90,8 +90,12 @@ will be computed.} of an error, try reducing the value of \code{tr}, which is by default set to \code{0.2}. Lowering the value might help.} -\item{k}{Number of digits after decimal point (should be an integer) -(Default: \code{k = 2L}).} +\item{digits}{Number of digits for rounding or significant figures. May also +be \code{"signif"} to return significant figures or \code{"scientific"} +to return scientific notation. Control the number of digits by adding the +value as suffix, e.g. \code{digits = "scientific4"} to have scientific +notation with 4 decimal places, or \code{digits = "signif5"} for 5 +significant figures (see also \code{\link[=signif]{signif()}}).} \item{results.subtitle}{Decides whether the results of statistical tests are to be displayed as a subtitle (Default: \code{TRUE}). If set to \code{FALSE}, only diff --git a/man/gghistostats.Rd b/man/gghistostats.Rd index 36af3bae4..f9a4dfab1 100644 --- a/man/gghistostats.Rd +++ b/man/gghistostats.Rd @@ -19,7 +19,7 @@ gghistostats( effsize.type = "g", conf.level = 0.95, tr = 0.2, - k = 2L, + digits = 2L, ggtheme = ggstatsplot::theme_ggstatsplot(), results.subtitle = TRUE, bin.args = list(color = "black", fill = "grey50", alpha = 0.7), @@ -92,8 +92,12 @@ will be computed.} of an error, try reducing the value of \code{tr}, which is by default set to \code{0.2}. Lowering the value might help.} -\item{k}{Number of digits after decimal point (should be an integer) -(Default: \code{k = 2L}).} +\item{digits}{Number of digits for rounding or significant figures. May also +be \code{"signif"} to return significant figures or \code{"scientific"} +to return scientific notation. Control the number of digits by adding the +value as suffix, e.g. \code{digits = "scientific4"} to have scientific +notation with 4 decimal places, or \code{digits = "signif5"} for 5 +significant figures (see also \code{\link[=signif]{signif()}}).} \item{ggtheme}{A \code{{ggplot2}} theme. Default value is \code{ggstatsplot::theme_ggstatsplot()}. Any of the \code{{ggplot2}} themes (e.g., diff --git a/man/ggpiestats.Rd b/man/ggpiestats.Rd index 497b178cf..3851298b8 100644 --- a/man/ggpiestats.Rd +++ b/man/ggpiestats.Rd @@ -15,9 +15,9 @@ ggpiestats( label = "percentage", label.args = list(direction = "both"), label.repel = FALSE, - k = 2L, + digits = 2L, proportion.test = results.subtitle, - perc.k = 0L, + digits.perc = 0L, bf.message = TRUE, ratio = NULL, conf.level = 0.95, @@ -66,9 +66,7 @@ represents a single observation.} You can specify just the initial letter.} \item{paired}{Logical indicating whether data came from a within-subjects or -repeated measures design study (Default: \code{FALSE}). If \code{TRUE}, McNemar's -test expression will be returned. If \code{FALSE}, Pearson's chi-square test will -be returned.} +repeated measures design study (Default: \code{FALSE}).} \item{results.subtitle}{Decides whether the results of statistical tests are to be displayed as a subtitle (Default: \code{TRUE}). If set to \code{FALSE}, only @@ -84,14 +82,18 @@ on the label in each pie slice. Possible options are \code{"percentage"} \item{label.repel}{Whether labels should be repelled using \code{{ggrepel}} package. This can be helpful in case the labels are overlapping.} -\item{k}{Number of digits after decimal point (should be an integer) -(Default: \code{k = 2L}).} +\item{digits}{Number of digits for rounding or significant figures. May also +be \code{"signif"} to return significant figures or \code{"scientific"} +to return scientific notation. Control the number of digits by adding the +value as suffix, e.g. \code{digits = "scientific4"} to have scientific +notation with 4 decimal places, or \code{digits = "signif5"} for 5 +significant figures (see also \code{\link[=signif]{signif()}}).} \item{proportion.test}{Decides whether proportion test for \code{x} variable is to be carried out for each level of \code{y}. Defaults to \code{results.subtitle}. In \code{ggbarstats}, only \emph{p}-values from this test will be displayed.} -\item{perc.k}{Numeric that decides number of decimal places for percentage +\item{digits.perc}{Numeric that decides number of decimal places for percentage labels (Default: \code{0L}).} \item{bf.message}{Logical that decides whether to display Bayes Factor in @@ -99,10 +101,10 @@ favor of the \emph{null} hypothesis. This argument is relevant only \strong{for parametric test} (Default: \code{TRUE}).} \item{ratio}{A vector of proportions: the expected proportions for the -proportion test (should sum to 1). Default is \code{NULL}, which means the null +proportion test (should sum to \code{1}). Default is \code{NULL}, which means the null is equal theoretical proportions across the levels of the nominal variable. -This means if there are two levels this will be \code{ratio = c(0.5,0.5)} or if -there are four levels this will be \code{ratio = c(0.25,0.25,0.25,0.25)}, etc.} +E.g., \code{ratio = c(0.5, 0.5)} for two levels, +\code{ratio = c(0.25, 0.25, 0.25, 0.25)} for four levels, etc.} \item{conf.level}{Scalar between \code{0} and \code{1} (default: \verb{95\%} confidence/credible intervals, \code{0.95}). If \code{NULL}, no confidence intervals diff --git a/man/ggscatterstats.Rd b/man/ggscatterstats.Rd index 532894e40..8499e8c08 100644 --- a/man/ggscatterstats.Rd +++ b/man/ggscatterstats.Rd @@ -13,7 +13,7 @@ ggscatterstats( bf.prior = 0.707, bf.message = TRUE, tr = 0.2, - k = 2L, + digits = 2L, results.subtitle = TRUE, label.var = NULL, label.expression = NULL, @@ -77,8 +77,12 @@ parametric test} (Default: \code{TRUE}).} of an error, try reducing the value of \code{tr}, which is by default set to \code{0.2}. Lowering the value might help.} -\item{k}{Number of digits after decimal point (should be an integer) -(Default: \code{k = 2L}).} +\item{digits}{Number of digits for rounding or significant figures. May also +be \code{"signif"} to return significant figures or \code{"scientific"} +to return scientific notation. Control the number of digits by adding the +value as suffix, e.g. \code{digits = "scientific4"} to have scientific +notation with 4 decimal places, or \code{digits = "signif5"} for 5 +significant figures (see also \code{\link[=signif]{signif()}}).} \item{results.subtitle}{Decides whether the results of statistical tests are to be displayed as a subtitle (Default: \code{TRUE}). If set to \code{FALSE}, only diff --git a/man/ggwithinstats.Rd b/man/ggwithinstats.Rd index 507e1238b..8d10dc446 100644 --- a/man/ggwithinstats.Rd +++ b/man/ggwithinstats.Rd @@ -20,7 +20,7 @@ ggwithinstats( caption = NULL, title = NULL, subtitle = NULL, - k = 2L, + digits = 2L, conf.level = 0.95, nboot = 100L, tr = 0.2, @@ -120,8 +120,12 @@ if \code{bf.message = FALSE}.} \item{subtitle}{The text for the plot subtitle. Will work only if \code{results.subtitle = FALSE}.} -\item{k}{Number of digits after decimal point (should be an integer) -(Default: \code{k = 2L}).} +\item{digits}{Number of digits for rounding or significant figures. May also +be \code{"signif"} to return significant figures or \code{"scientific"} +to return scientific notation. Control the number of digits by adding the +value as suffix, e.g. \code{digits = "scientific4"} to have scientific +notation with 4 decimal places, or \code{digits = "signif5"} for 5 +significant figures (see also \code{\link[=signif]{signif()}}).} \item{conf.level}{Scalar between \code{0} and \code{1} (default: \verb{95\%} confidence/credible intervals, \code{0.95}). If \code{NULL}, no confidence intervals diff --git a/man/grouped_ggbarstats.Rd b/man/grouped_ggbarstats.Rd index e8ecebfb2..66bad0ed4 100644 --- a/man/grouped_ggbarstats.Rd +++ b/man/grouped_ggbarstats.Rd @@ -35,7 +35,7 @@ for \code{ggbarstats} function.} \item{\code{proportion.test}}{Decides whether proportion test for \code{x} variable is to be carried out for each level of \code{y}. Defaults to \code{results.subtitle}. In \code{ggbarstats}, only \emph{p}-values from this test will be displayed.} - \item{\code{perc.k}}{Numeric that decides number of decimal places for percentage + \item{\code{digits.perc}}{Numeric that decides number of decimal places for percentage labels (Default: \code{0L}).} \item{\code{label}}{Character decides what information needs to be displayed on the label in each pie slice. Possible options are \code{"percentage"} @@ -79,22 +79,24 @@ thus the details as well.} } You can specify just the initial letter.} - \item{\code{k}}{Number of digits after decimal point (should be an integer) -(Default: \code{k = 2L}).} + \item{\code{digits}}{Number of digits for rounding or significant figures. May also +be \code{"signif"} to return significant figures or \code{"scientific"} +to return scientific notation. Control the number of digits by adding the +value as suffix, e.g. \code{digits = "scientific4"} to have scientific +notation with 4 decimal places, or \code{digits = "signif5"} for 5 +significant figures (see also \code{\link[=signif]{signif()}}).} \item{\code{conf.level}}{Scalar between \code{0} and \code{1} (default: \verb{95\%} confidence/credible intervals, \code{0.95}). If \code{NULL}, no confidence intervals will be computed.} \item{\code{paired}}{Logical indicating whether data came from a within-subjects or -repeated measures design study (Default: \code{FALSE}). If \code{TRUE}, McNemar's -test expression will be returned. If \code{FALSE}, Pearson's chi-square test will -be returned.} +repeated measures design study (Default: \code{FALSE}).} \item{\code{counts}}{The variable in data containing counts, or \code{NULL} if each row represents a single observation.} \item{\code{ratio}}{A vector of proportions: the expected proportions for the -proportion test (should sum to 1). Default is \code{NULL}, which means the null +proportion test (should sum to \code{1}). Default is \code{NULL}, which means the null is equal theoretical proportions across the levels of the nominal variable. -This means if there are two levels this will be \code{ratio = c(0.5,0.5)} or if -there are four levels this will be \code{ratio = c(0.25,0.25,0.25,0.25)}, etc.} +E.g., \code{ratio = c(0.5, 0.5)} for two levels, +\code{ratio = c(0.25, 0.25, 0.25, 0.25)} for four levels, etc.} \item{\code{sampling.plan}}{Character describing the sampling plan. Possible options are \code{"indepMulti"} (independent multinomial; default), \code{"poisson"}, \code{"jointMulti"} (joint multinomial), \code{"hypergeom"} (hypergeometric). For diff --git a/man/grouped_ggbetweenstats.Rd b/man/grouped_ggbetweenstats.Rd index 7f82f6333..f1ede1975 100644 --- a/man/grouped_ggbetweenstats.Rd +++ b/man/grouped_ggbetweenstats.Rd @@ -121,8 +121,12 @@ subject-1,subject-2, ..., pattern.} } You can specify just the initial letter.} - \item{\code{k}}{Number of digits after decimal point (should be an integer) -(Default: \code{k = 2L}).} + \item{\code{digits}}{Number of digits for rounding or significant figures. May also +be \code{"signif"} to return significant figures or \code{"scientific"} +to return scientific notation. Control the number of digits by adding the +value as suffix, e.g. \code{digits = "scientific4"} to have scientific +notation with 4 decimal places, or \code{digits = "signif5"} for 5 +significant figures (see also \code{\link[=signif]{signif()}}).} \item{\code{conf.level}}{Scalar between \code{0} and \code{1} (default: \verb{95\%} confidence/credible intervals, \code{0.95}). If \code{NULL}, no confidence intervals will be computed.} diff --git a/man/grouped_ggcorrmat.Rd b/man/grouped_ggcorrmat.Rd index e3130d2fc..af09b9338 100644 --- a/man/grouped_ggcorrmat.Rd +++ b/man/grouped_ggcorrmat.Rd @@ -52,8 +52,12 @@ used: \code{corr}, \code{method}, \code{p.mat}, \code{sig.level}, \code{ggtheme} } You can specify just the initial letter.} - \item{\code{k}}{Number of digits after decimal point (should be an integer) -(Default: \code{k = 2L}).} + \item{\code{digits}}{Number of digits for rounding or significant figures. May also +be \code{"signif"} to return significant figures or \code{"scientific"} +to return scientific notation. Control the number of digits by adding the +value as suffix, e.g. \code{digits = "scientific4"} to have scientific +notation with 4 decimal places, or \code{digits = "signif5"} for 5 +significant figures (see also \code{\link[=signif]{signif()}}).} \item{\code{conf.level}}{Scalar between \code{0} and \code{1} (default: \verb{95\%} confidence/credible intervals, \code{0.95}). If \code{NULL}, no confidence intervals will be computed.} diff --git a/man/grouped_ggdotplotstats.Rd b/man/grouped_ggdotplotstats.Rd index 1a1c65064..355abc844 100644 --- a/man/grouped_ggdotplotstats.Rd +++ b/man/grouped_ggdotplotstats.Rd @@ -39,8 +39,12 @@ centrality parameter.} You can specify just the initial letter.} \item{\code{test.value}}{A number indicating the true value of the mean (Default: \code{0}).} - \item{\code{k}}{Number of digits after decimal point (should be an integer) -(Default: \code{k = 2L}).} + \item{\code{digits}}{Number of digits for rounding or significant figures. May also +be \code{"signif"} to return significant figures or \code{"scientific"} +to return scientific notation. Control the number of digits by adding the +value as suffix, e.g. \code{digits = "scientific4"} to have scientific +notation with 4 decimal places, or \code{digits = "signif5"} for 5 +significant figures (see also \code{\link[=signif]{signif()}}).} \item{\code{conf.level}}{Scalar between \code{0} and \code{1} (default: \verb{95\%} confidence/credible intervals, \code{0.95}). If \code{NULL}, no confidence intervals will be computed.} diff --git a/man/grouped_gghistostats.Rd b/man/grouped_gghistostats.Rd index e92a46ea3..15e2d883e 100644 --- a/man/grouped_gghistostats.Rd +++ b/man/grouped_gghistostats.Rd @@ -61,8 +61,12 @@ centrality parameter.} You can specify just the initial letter.} \item{\code{test.value}}{A number indicating the true value of the mean (Default: \code{0}).} - \item{\code{k}}{Number of digits after decimal point (should be an integer) -(Default: \code{k = 2L}).} + \item{\code{digits}}{Number of digits for rounding or significant figures. May also +be \code{"signif"} to return significant figures or \code{"scientific"} +to return scientific notation. Control the number of digits by adding the +value as suffix, e.g. \code{digits = "scientific4"} to have scientific +notation with 4 decimal places, or \code{digits = "signif5"} for 5 +significant figures (see also \code{\link[=signif]{signif()}}).} \item{\code{conf.level}}{Scalar between \code{0} and \code{1} (default: \verb{95\%} confidence/credible intervals, \code{0.95}). If \code{NULL}, no confidence intervals will be computed.} diff --git a/man/grouped_ggpiestats.Rd b/man/grouped_ggpiestats.Rd index b43faceb7..6c35a8df2 100644 --- a/man/grouped_ggpiestats.Rd +++ b/man/grouped_ggpiestats.Rd @@ -33,7 +33,7 @@ for \code{ggbarstats} function.} \item{\code{proportion.test}}{Decides whether proportion test for \code{x} variable is to be carried out for each level of \code{y}. Defaults to \code{results.subtitle}. In \code{ggbarstats}, only \emph{p}-values from this test will be displayed.} - \item{\code{perc.k}}{Numeric that decides number of decimal places for percentage + \item{\code{digits.perc}}{Numeric that decides number of decimal places for percentage labels (Default: \code{0L}).} \item{\code{label}}{Character decides what information needs to be displayed on the label in each pie slice. Possible options are \code{"percentage"} @@ -79,22 +79,24 @@ thus the details as well.} } You can specify just the initial letter.} - \item{\code{k}}{Number of digits after decimal point (should be an integer) -(Default: \code{k = 2L}).} + \item{\code{digits}}{Number of digits for rounding or significant figures. May also +be \code{"signif"} to return significant figures or \code{"scientific"} +to return scientific notation. Control the number of digits by adding the +value as suffix, e.g. \code{digits = "scientific4"} to have scientific +notation with 4 decimal places, or \code{digits = "signif5"} for 5 +significant figures (see also \code{\link[=signif]{signif()}}).} \item{\code{conf.level}}{Scalar between \code{0} and \code{1} (default: \verb{95\%} confidence/credible intervals, \code{0.95}). If \code{NULL}, no confidence intervals will be computed.} \item{\code{paired}}{Logical indicating whether data came from a within-subjects or -repeated measures design study (Default: \code{FALSE}). If \code{TRUE}, McNemar's -test expression will be returned. If \code{FALSE}, Pearson's chi-square test will -be returned.} +repeated measures design study (Default: \code{FALSE}).} \item{\code{counts}}{The variable in data containing counts, or \code{NULL} if each row represents a single observation.} \item{\code{ratio}}{A vector of proportions: the expected proportions for the -proportion test (should sum to 1). Default is \code{NULL}, which means the null +proportion test (should sum to \code{1}). Default is \code{NULL}, which means the null is equal theoretical proportions across the levels of the nominal variable. -This means if there are two levels this will be \code{ratio = c(0.5,0.5)} or if -there are four levels this will be \code{ratio = c(0.25,0.25,0.25,0.25)}, etc.} +E.g., \code{ratio = c(0.5, 0.5)} for two levels, +\code{ratio = c(0.25, 0.25, 0.25, 0.25)} for four levels, etc.} \item{\code{sampling.plan}}{Character describing the sampling plan. Possible options are \code{"indepMulti"} (independent multinomial; default), \code{"poisson"}, \code{"jointMulti"} (joint multinomial), \code{"hypergeom"} (hypergeometric). For diff --git a/man/grouped_ggscatterstats.Rd b/man/grouped_ggscatterstats.Rd index bbf390ad6..e97d6fd62 100644 --- a/man/grouped_ggscatterstats.Rd +++ b/man/grouped_ggscatterstats.Rd @@ -59,8 +59,12 @@ be plotted on the \code{y}-axis.} } You can specify just the initial letter.} - \item{\code{k}}{Number of digits after decimal point (should be an integer) -(Default: \code{k = 2L}).} + \item{\code{digits}}{Number of digits for rounding or significant figures. May also +be \code{"signif"} to return significant figures or \code{"scientific"} +to return scientific notation. Control the number of digits by adding the +value as suffix, e.g. \code{digits = "scientific4"} to have scientific +notation with 4 decimal places, or \code{digits = "signif5"} for 5 +significant figures (see also \code{\link[=signif]{signif()}}).} \item{\code{conf.level}}{Scalar between \code{0} and \code{1} (default: \verb{95\%} confidence/credible intervals, \code{0.95}). If \code{NULL}, no confidence intervals will be computed.} diff --git a/man/grouped_ggwithinstats.Rd b/man/grouped_ggwithinstats.Rd index 8fe0b80aa..d36b7368b 100644 --- a/man/grouped_ggwithinstats.Rd +++ b/man/grouped_ggwithinstats.Rd @@ -130,8 +130,12 @@ subject-1,subject-2, ..., pattern.} } You can specify just the initial letter.} - \item{\code{k}}{Number of digits after decimal point (should be an integer) -(Default: \code{k = 2L}).} + \item{\code{digits}}{Number of digits for rounding or significant figures. May also +be \code{"signif"} to return significant figures or \code{"scientific"} +to return scientific notation. Control the number of digits by adding the +value as suffix, e.g. \code{digits = "scientific4"} to have scientific +notation with 4 decimal places, or \code{digits = "signif5"} for 5 +significant figures (see also \code{\link[=signif]{signif()}}).} \item{\code{conf.level}}{Scalar between \code{0} and \code{1} (default: \verb{95\%} confidence/credible intervals, \code{0.95}). If \code{NULL}, no confidence intervals will be computed.} diff --git a/old/purrr_examples.Rmd b/old/purrr_examples.Rmd index 695136e53..0d9ee3a9e 100644 --- a/old/purrr_examples.Rmd +++ b/old/purrr_examples.Rmd @@ -159,7 +159,7 @@ plot_list <- purrr::pmap( pairwise.display = list("s", "ns", "all"), p.adjust.method = list("hommel", "bonferroni", "BH"), conf.level = list(0.99, 0.95, 0.90), - k = list(1, 2, 3), + digits = list(1L, 2L, 3L), effsize.type = list( NULL, "partial_omega", @@ -233,7 +233,7 @@ plot_list <- purrr::pmap( pairwise.display = list("ns", "s", "ns", "all"), p.adjust.method = list("fdr", "hommel", "bonferroni", "BH"), conf.level = list(0.99, 0.99, 0.95, 0.90), - k = list(3, 2, 2, 3), + digits = list(3L, 2L, 2L, 3L), effsize.type = list( "omega", "eta", diff --git a/tests/testthat/test-ggbarstats.R b/tests/testthat/test-ggbarstats.R index baaae9eec..a283bb2f7 100644 --- a/tests/testthat/test-ggbarstats.R +++ b/tests/testthat/test-ggbarstats.R @@ -105,7 +105,7 @@ test_that( data = mtcars, x = am, y = cyl, - perc.k = 2L, + digits.perc = 2L, title = "mtcars dataset", package = "wesanderson", palette = "Royal2", @@ -186,7 +186,7 @@ test_that( data = ggplot2::msleep, x = conservation, y = vore, - k = 4L + digits = 4L ) %>% extract_subtitle() @@ -195,7 +195,7 @@ test_that( data = ggplot2::msleep, x = conservation, y = vore, - k = 4L + digits = 4L ))$expression[[1L]] expect_identical(p_sub, stats_output) diff --git a/tests/testthat/test-ggcoefstats.R b/tests/testthat/test-ggcoefstats.R index 12d27ee56..0e5cfa18d 100644 --- a/tests/testthat/test-ggcoefstats.R +++ b/tests/testthat/test-ggcoefstats.R @@ -99,7 +99,7 @@ test_that( only.significant = TRUE, package = "ggsci", palette = "category20c_d3", - k = 3L + digits = 3L )) ) @@ -122,7 +122,7 @@ test_that( subtitle = "Source: `{ggplot2}` package", package = "wesanderson", palette = "BottleRocket2", - k = 3L + digits = 3L ) ) } diff --git a/tests/testthat/test-ggcorrmat.R b/tests/testthat/test-ggcorrmat.R index 2009c1fcb..91f37c6e1 100644 --- a/tests/testthat/test-ggcorrmat.R +++ b/tests/testthat/test-ggcorrmat.R @@ -32,7 +32,7 @@ test_that( matrix.type = "full", p.adjust.method = "fdr", colors = NULL, - k = 4L, + digits = 4L, ggcorrplot.args = list( lab_col = "white", pch.col = "white" diff --git a/tests/testthat/test-ggpiestats.R b/tests/testthat/test-ggpiestats.R index 021a03b53..cbd908a3b 100644 --- a/tests/testthat/test-ggpiestats.R +++ b/tests/testthat/test-ggpiestats.R @@ -113,7 +113,7 @@ test_that( mtcars, x = am, y = cyl, - perc.k = 2L, + digits.perc = 2L, title = "mtcars dataset", package = "wesanderson", palette = "Royal2", @@ -172,7 +172,7 @@ test_that( ggplot2::msleep, x = conservation, y = vore, - k = 4L + digits = 4L ) %>% extract_subtitle() @@ -181,7 +181,7 @@ test_that( ggplot2::msleep, x = conservation, y = vore, - k = 4L + digits = 4L ))$expression[[1L]] expect_identical(p_sub, stats_output) diff --git a/tests/testthat/test-pairwise-ggsignif.R b/tests/testthat/test-pairwise-ggsignif.R index eb78cf6cc..24340a826 100644 --- a/tests/testthat/test-pairwise-ggsignif.R +++ b/tests/testthat/test-pairwise-ggsignif.R @@ -14,7 +14,7 @@ test_that( results.subtitle = FALSE, p.adjust.method = "fdr", pairwise.display = "ns", - k = 3L + digits = 3L ) ) @@ -29,7 +29,7 @@ test_that( results.subtitle = FALSE, p.adjust.method = "fdr", pairwise.display = "s", - k = 3L + digits = 3L ) ) @@ -44,7 +44,7 @@ test_that( results.subtitle = FALSE, p.adjust.method = "fdr", pairwise.display = "all", - k = 3L + digits = 3L ) ) @@ -59,7 +59,7 @@ test_that( results.subtitle = FALSE, p.adjust.method = "bonferroni", pairwise.display = "ns", - k = 3L + digits = 3L ) ) @@ -74,7 +74,7 @@ test_that( results.subtitle = FALSE, p.adjust.method = "bonferroni", pairwise.display = "s", - k = 3L + digits = 3L ) ) @@ -89,7 +89,7 @@ test_that( results.subtitle = FALSE, p.adjust.method = "bonferroni", pairwise.display = "all", - k = 3L + digits = 3L ) ) @@ -104,7 +104,7 @@ test_that( results.subtitle = FALSE, p.adjust.method = "holm", pairwise.display = "ns", - k = 3L + digits = 3L ) ) @@ -119,7 +119,7 @@ test_that( results.subtitle = FALSE, p.adjust.method = "holm", pairwise.display = "s", - k = 3L + digits = 3L ) ) @@ -134,7 +134,7 @@ test_that( results.subtitle = FALSE, p.adjust.method = "holm", pairwise.display = "all", - k = 3L + digits = 3L ) ) @@ -147,7 +147,7 @@ test_that( mpg, type = "bayes", results.subtitle = FALSE, - k = 3L + digits = 3L ) ) } @@ -169,7 +169,7 @@ test_that( results.subtitle = FALSE, p.adjust.method = "fdr", pairwise.display = "ns", - k = 3L + digits = 3L ) ) @@ -184,7 +184,7 @@ test_that( results.subtitle = FALSE, p.adjust.method = "fdr", pairwise.display = "s", - k = 3L + digits = 3L ) ) @@ -199,7 +199,7 @@ test_that( results.subtitle = FALSE, p.adjust.method = "fdr", pairwise.display = "all", - k = 3L + digits = 3L ) ) @@ -214,7 +214,7 @@ test_that( results.subtitle = FALSE, p.adjust.method = "bonferroni", pairwise.display = "ns", - k = 3L + digits = 3L ) ) @@ -229,7 +229,7 @@ test_that( results.subtitle = FALSE, p.adjust.method = "bonferroni", pairwise.display = "s", - k = 3L + digits = 3L ) ) @@ -244,7 +244,7 @@ test_that( results.subtitle = FALSE, p.adjust.method = "bonferroni", pairwise.display = "all", - k = 3L + digits = 3L ) ) @@ -259,7 +259,7 @@ test_that( results.subtitle = FALSE, p.adjust.method = "holm", pairwise.display = "ns", - k = 3L + digits = 3L ) ) @@ -274,7 +274,7 @@ test_that( results.subtitle = FALSE, p.adjust.method = "holm", pairwise.display = "s", - k = 3L + digits = 3L ) ) @@ -289,7 +289,7 @@ test_that( results.subtitle = FALSE, p.adjust.method = "holm", pairwise.display = "all", - k = 3L + digits = 3L ) ) @@ -302,7 +302,7 @@ test_that( desire, type = "bayes", results.subtitle = FALSE, - k = 3L + digits = 3L ) ) } @@ -326,7 +326,7 @@ test_that( bf.message = FALSE, p.adjust.method = "fdr", pairwise.display = "ns", - k = 3L + digits = 3L ) ) } diff --git a/vignettes/web_only/faq.Rmd b/vignettes/web_only/faq.Rmd index 6918a5a8d..451f251aa 100644 --- a/vignettes/web_only/faq.Rmd +++ b/vignettes/web_only/faq.Rmd @@ -632,6 +632,29 @@ ggbetweenstats( ) ``` +## 29. How to turn off scientific notation in expressions? + +```{r} +set.seed(123) +library(ggstatsplot) +library(WRS2) + +ggwithinstats( + WineTasting, + Wine, + Taste, + paired = TRUE +) + +ggwithinstats( + WineTasting, + Wine, + Taste, + paired = TRUE, + digits = 4L +) +``` + ## 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 9352173c7..6956f0b64 100644 --- a/vignettes/web_only/ggbarstats.Rmd +++ b/vignettes/web_only/ggbarstats.Rmd @@ -153,7 +153,7 @@ grouped_ggbarstats( x = Survived, y = Sex, grouping.var = Age, - perc.k = 1, + digits.perc = 1, package = "ggsci", palette = "category10_d3", # arguments relevant for `combine_plots()` diff --git a/vignettes/web_only/ggbetweenstats.Rmd b/vignettes/web_only/ggbetweenstats.Rmd index 663b6871d..05032ba48 100644 --- a/vignettes/web_only/ggbetweenstats.Rmd +++ b/vignettes/web_only/ggbetweenstats.Rmd @@ -227,7 +227,7 @@ p3 <- ggbetweenstats( tr = 0.005, package = "wesanderson", palette = "Royal2", - k = 3 + digits = 3 ) ## Bayes Factor for parametric t-test and boxviolin plot diff --git a/vignettes/web_only/ggcoefstats.Rmd b/vignettes/web_only/ggcoefstats.Rmd index ed4851efb..3e3f5b363 100644 --- a/vignettes/web_only/ggcoefstats.Rmd +++ b/vignettes/web_only/ggcoefstats.Rmd @@ -186,7 +186,7 @@ ggcoefstats( x = afit, title = "Aalen's additive regression model", subtitle = "(for censored data)", - k = 3 + digits = 3 ) ``` @@ -407,13 +407,13 @@ combine_plots( ggcoefstats( x = br$gam, title = "generalized additive model (parametric terms)", - k = 3 + digits = 3 ), # second object plot ggcoefstats( x = br$mer, title = "linear mixed-effects model", - k = 3 + digits = 3 ) ), plotgrid.args = list(nrow = 1) diff --git a/vignettes/web_only/ggpiestats.Rmd b/vignettes/web_only/ggpiestats.Rmd index 3c81b0995..ee8e0284b 100644 --- a/vignettes/web_only/ggpiestats.Rmd +++ b/vignettes/web_only/ggpiestats.Rmd @@ -163,7 +163,7 @@ grouped_ggpiestats( x = Survived, y = Sex, grouping.var = Age, - perc.k = 1, + digits.perc = 1, package = "ggsci", palette = "category10_d3", # arguments relevant for `combine_plots()` diff --git a/vignettes/web_only/ggwithinstats.Rmd b/vignettes/web_only/ggwithinstats.Rmd index 6c77ac608..342e5c26f 100644 --- a/vignettes/web_only/ggwithinstats.Rmd +++ b/vignettes/web_only/ggwithinstats.Rmd @@ -271,7 +271,7 @@ grouped_ggwithinstats( # ggtheme = ggthemes::theme_tufte(), package = "ggsci", palette = "default_jco", - k = 3, + digits = 3, ## arguments relevant for combine_plots annotation.args = list(title = "Desire to kill bugs across genders"), plotgrid.args = list(ncol = 1) diff --git a/vignettes/web_only/purrr_examples.Rmd b/vignettes/web_only/purrr_examples.Rmd index 63925c917..9af9fb676 100644 --- a/vignettes/web_only/purrr_examples.Rmd +++ b/vignettes/web_only/purrr_examples.Rmd @@ -140,7 +140,7 @@ plot_list <- purrr::pmap( pairwise.display = list("s", "ns", "all"), p.adjust.method = list("hommel", "bonferroni", "BH"), conf.level = list(0.99, 0.95, 0.90), - k = list(1, 2, 3), + digits = list(1, 2, 3), effsize.type = list( NULL, "partial_omega", @@ -206,7 +206,7 @@ plot_list <- purrr::pmap( pairwise.display = list("ns", "s", "ns", "all"), p.adjust.method = list("fdr", "hommel", "bonferroni", "BH"), conf.level = list(0.99, 0.99, 0.95, 0.90), - k = list(3, 2, 2, 3), + digits = list(3, 2, 2, 3), effsize.type = list( "omega", "eta",