test_t: Student's t-test (with automatic diagnostics)

View source: R/T_test.R

test_tR Documentation

Student's t-test (with automatic diagnostics)

Description

Performs Student's t-test to compare the means of two independent groups, with automatic checks for normality and homogeneity of variances. If the assumptions are violated, the Mann-Whitney U test is applied automatically, without generating a plot.

Usage

test_t(
  ...,
  title = TRUE,
  title_text = "t-test",
  xlab = "Group",
  ylab = "Value",
  style = c("boxplot", "violin", "mono", "halfeye"),
  colors = NULL,
  help = FALSE,
  verbose = TRUE
)

Arguments

...

Two numeric vectors or a data frame containing exactly two columns.

title

Logical. If TRUE, adds a title to the plot.

title_text

Character string specifying the plot title. Default: t-test.

xlab

Character string specifying the x-axis label. Default: Group.

ylab

Character string specifying the y-axis label. Default: Value.

style

Character string specifying the plot style generated by the function. One of boxplot, violin, mono, or halfeye. Default: boxplot.

colors

Optional character vector specifying the box colors.

help

Logical. If TRUE, displays a detailed explanation of the function. Default: FALSE.

verbose

Logical. If TRUE, prints detailed messages. Default: TRUE.

Value

An object of class test_t containing the following components:

  • summary: Summary statistics, including group means, standard deviations (SD), and group information.

  • result: Test results, including the test statistic, degrees of freedom (DF), and p-value.

  • method: The statistical method selected for the analysis.

  • normality: Results of the normality assessment.

  • homogeneity: Results of the homogeneity of variances assessment.

  • plot: Plot parameters and related information.

Examples

set.seed(123)
df <- data.frame(
  control = rnorm(30, mean = 10),
  treatment = rnorm(30, mean = 15)
)
test_t(df)

autotestR documentation built on Oct. 27, 2026, 1:07 a.m.