Skip to contents

Automatically selects and generates the most appropriate statistical visualization based on variable data types. Supports both independent and repeated measures designs with various plot types including violin plots, scatter plots, bar charts, and alluvial diagrams.

Usage

statsplot2(
  data,
  dep,
  group,
  grvar,
  direction = "independent",
  distribution = "p",
  alluvsty = "t1",
  excl = FALSE,
  originaltheme = FALSE
)

Arguments

data

The data as a data frame.

dep

The dependent variable (y-axis, 1st measurement). Can be continuous or categorical.

group

The grouping variable (x-axis, 2nd measurement). Can be continuous or categorical.

grvar

Optional grouping variable for creating grouped plots across multiple panels.

direction

Measurement design type. "independent" for between-subjects comparisons, "repeated" for within-subjects/repeated measures comparisons.

distribution

Statistical approach: "p" = parametric, "np" = nonparametric, "r" = robust, "bf" = Bayes factor.

alluvsty

Style for alluvial diagrams: "t1" = ggalluvial with stratum labels, "t2" = easyalluvial with automatic variable selection.

excl

If TRUE, excludes rows with missing values before analysis.

originaltheme

If TRUE, uses original ggplot2 themes instead of ggstatsplot themes.

Value

A results object containing:

results$todoa html
results$text4a preformatted
results$plotan image

Examples

# Automatic plot selection for factor vs continuous variables
statsplot2(
    data = mtcars,
    dep = "mpg",
    group = "cyl",
    direction = "independent",
    distribution = "p"
)
#> Error in statsplot2(data = mtcars, dep = "mpg", group = "cyl", direction = "independent",     distribution = "p"): argument "grvar" is missing, with no default

# Repeated measures with alluvial diagram
statsplot2(
    data = survey_data,
    dep = "condition_baseline",
    group = "condition_followup",
    direction = "repeated",
    alluvsty = "t1"
)
#> Error in statsplot2(data = survey_data, dep = "condition_baseline", group = "condition_followup",     direction = "repeated", alluvsty = "t1"): argument "grvar" is missing, with no default