Learn R Programming

colleyRstats (version 0.0.1)

reportggstatsplotPostHoc: Report significant post-hoc pairwise comparisons

Description

This function extracts significant pairwise comparisons from a ggstatsplot object, calculates the mean and standard deviation for the groups involved using the raw data, and prints LaTeX-formatted sentences reporting the results.

Usage

reportggstatsplotPostHoc(
  data,
  p,
  iv = "testiv",
  dv = "testdv",
  label_mappings = NULL
)

Value

No return value. The function prints LaTeX-formatted text to the console.

Arguments

data

A data frame containing the raw data used to generate the plot.

p

A ggstatsplot object (e.g., returned by ggbetweenstats) containing the pairwise comparison statistics.

iv

Character string. The column name of the independent variable (grouping variable).

dv

Character string. The column name of the dependent variable.

label_mappings

Optional named list or vector. Used to rename factor levels in the output text (e.g., list("old_name" = "New Label")).

LaTeX Requirements

To easily copy and paste the results to your manuscript, the following commands (or similar) must be defined in your LaTeX preamble, as the function outputs commands taking arguments (e.g., \m{value}):


  \newcommand{\m}[1]{\textit{M}=#1}
  \newcommand{\sd}[1]{\textit{SD}=#1}
  \newcommand{\padj}[1]{$p_{adj}=#1$}
  \newcommand{\padjminor}[1]{$p_{adj}<#1$}

Examples

Run this code
# \donttest{
library(ggstatsplot)
library(dplyr)

# Generate a plot
plt <- ggbetweenstats(mtcars, am, mpg)

# Report stats
reportggstatsplotPostHoc(
  data = mtcars,
  p = plt,
  iv = "am",
  dv = "mpg",
  label_mappings = list("0" = "Automatic", "1" = "Manual")
)
# }

Run the code above in your browser using DataLab