50% off: Unlimited data and AI learning.
State of Data and AI Literacy Report 2025

exploratory (version 0.3.31)

compare_groups: Compare groups

Description

Compares groups by (1) creating histogram by group; (2) summarizing descriptive statistics by group; and (3) conducting pairwise comparisons (t-tests and Mann-Whitney tests).

Usage

compare_groups(
  data = NULL,
  iv_name = NULL,
  dv_name = NULL,
  sigfigs = 3,
  mann_whitney = TRUE,
  t_test_stats = FALSE
)

Value

the output will be a list of (1) ggplot object (histogram by group) (2) a data.table with descriptive statistics by group; and (3) a data.table with pairwise comparison results

Arguments

data

a data object (a data frame or a data.table)

iv_name

name of the independent variable (grouping variable)

dv_name

name of the dependent variable (measure variable of interest)

sigfigs

number of significant digits to round to

mann_whitney

if mann_whitney = TRUE, Mann-Whitney test results will be included in the pairwise comparison data.table. If mann_whitney = FALSE, Mann-Whitney tests will not be performed.

t_test_stats

if t_test_stats = TRUE, t-test statistic and degrees of freedom will be included in the pairwise comparison data.table.

Examples

Run this code
compare_groups(data = iris, iv_name = "Species", dv_name = "Sepal.Length")

Run the code above in your browser using DataLab