make_independent_t_test_table: Create a one-row summary table for an independent-samples...

View source: R/make_independent_t_test_table.R

make_independent_t_test_tableR Documentation

Create a one-row summary table for an independent-samples t-test

Description

This function performs an independent-samples t-test (Welch's t-test by default) between two groups defined by a binary grouping variable and returns a single-row data frame. The output includes group names, sample sizes, mean difference, test statistics, p-value, and effect size (Cohen's d) with a qualitative interpretation.

Usage

make_independent_t_test_table(data, outcome, group)

Arguments

data

A data frame containing the outcome and grouping variables.

outcome

Character string specifying the numeric outcome variable.

group

Character string specifying the grouping variable. Must have exactly two levels.

Details

The function is intended for streamlined reporting and does not introduce new statistical methods. All computations rely on stats::t.test().

Welch’s t-test is used by default, which does not assume equal variances. Cohen’s d is computed using the pooled standard deviation for comparability with conventional benchmarks. Group ordering follows the factor level order of the grouping variable.

Value

A single-row data frame with the following columns:

  • test: Name of the statistical test

  • group1, group2: Group labels

  • mean_diff: Mean difference between groups (group1 - group2)

  • t_value: t statistic

  • df: Degrees of freedom

  • p_value: p-value

  • n_group1, n_group2: Sample sizes per group

  • cohens_d: Cohen's d effect size

  • interpretation: Qualitative interpretation of effect size

Examples

set.seed(123)

data_t <- data.frame(
  group = rep(c("CBT", "Psychodynamic"), each = 30),
  score = c(
    rnorm(30, mean = 18, sd = 4),
    rnorm(30, mean = 21, sd = 4)
  )
)

make_independent_t_test_table(
  data = data_t,
  outcome = "score",
  group = "group"
)

scaledescr documentation built on April 11, 2026, 5:07 p.m.