Skip to contents

Wrapper Function for ggstatsplot::ggbetweenstats and ggstatsplot::grouped_ggbetweenstats to generate Box-Violin Plots for comparing continuous variables between groups with statistical annotations.

Usage

jjbetweenstats(
  data,
  dep,
  group,
  grvar = NULL,
  centralityplotting = FALSE,
  centralitytype = "parametric",
  typestatistics = "parametric",
  pairwisecomparisons = FALSE,
  pairwisedisplay = "significant",
  padjustmethod = "holm",
  effsizetype = "biased",
  mytitle = "Within Group Comparison",
  xtitle = "",
  ytitle = "",
  originaltheme = FALSE,
  resultssubtitle = FALSE,
  bfmessage = FALSE,
  k = 2,
  conflevel = 0.95,
  varequal = FALSE,
  plotwidth = 650,
  plotheight = 450,
  colorblindSafe = FALSE,
  addGGPubrPlot = FALSE,
  ggpubrPlotType = "boxplot",
  ggpubrPalette = "jco",
  ggpubrAddStats = TRUE,
  ggpubrAddPoints = FALSE
)

Arguments

data

The data as a data frame.

dep

.

group

.

grvar

.

centralityplotting

.

centralitytype

.

typestatistics

.

pairwisecomparisons

.

pairwisedisplay

.

padjustmethod

.

effsizetype

.

mytitle

.

xtitle

.

ytitle

.

originaltheme

.

resultssubtitle

.

bfmessage

Whether to display Bayes Factor in the subtitle when using Bayesian analysis.

k

Number of decimal places for displaying statistics in the subtitle.

conflevel

Confidence level for confidence intervals.

varequal

Whether to assume equal variances across groups for parametric tests.

plotwidth

Width of the plot in pixels. Default is 650.

plotheight

Height of the plot in pixels. Default is 450.

colorblindSafe

Whether to use colorblind-safe color palette for plot elements.

addGGPubrPlot

Add publication-ready plot using ggpubr package. This provides an alternative visualization with publication-quality aesthetics.

ggpubrPlotType

Type of ggpubr plot to display when addGGPubrPlot is enabled.

ggpubrPalette

Color palette for ggpubr plot.

ggpubrAddStats

Add statistical comparison p-values to ggpubr plot.

ggpubrAddPoints

Overlay individual data points on ggpubr plot.

Value

A results object containing:

results$todoa html
results$plot2an image
results$plotan image
results$ggpubrPlotan image
results$ggpubrPlot2an image

Examples

# Basic comparison between groups
jjbetweenstats(
    data = iris,
    dep = "Sepal.Length",
    group = "Species",
    typestatistics = "parametric",
    pairwisecomparisons = TRUE
)

# Multiple variables comparison
jjbetweenstats(
    data = mtcars,
    dep = c("mpg", "hp", "wt"),
    group = "cyl",
    typestatistics = "nonparametric",
    pairwisecomparisons = TRUE,
    pairwisedisplay = "significant",
    padjustmethod = "bonferroni"
)

# Grouped analysis with split variable
jjbetweenstats(
    data = mtcars,
    dep = "mpg",
    group = "cyl",
    grvar = "am",
    typestatistics = "robust",
    centralityplotting = TRUE,
    centralitytype = "robust",
)

# Bayesian analysis with custom aesthetics
jjbetweenstats(
    data = ToothGrowth,
    dep = "len",
    group = "supp",
    grvar = "dose",
    typestatistics = "bayes",
    bfmessage = TRUE,
    mytitle = "Tooth Growth by Supplement Type",
    xtitle = "Supplement",
    ytitle = "Tooth Length"
)