Learn R Programming

EnTraineR (version 1.0.0)

trainer_t_test: Interpret a Student's t-test (stats::t.test) with an LLM-ready prompt

Description

Builds a clear, audience-tailored prompt to interpret a base R stats::t.test() result. Identifies the test flavor (One-sample, Two-sample, Paired, Welch) and instructs the LLM to use ONLY printed values (p, t, df, CI, estimates) and avoid any new calculations.

Usage

trainer_t_test(
  tt_obj,
  introduction = NULL,
  alpha = 0.05,
  audience = c("beginner", "applied", "advanced"),
  summary_only = FALSE,
  llm_model = "llama3",
  generate = FALSE
)

Value

If generate = FALSE, the prompt string. Else a list with prompt, response, model.

Arguments

tt_obj

An htest object returned by stats::t.test().

introduction

Optional character string giving the study context in plain English.

alpha

Numeric significance level used for interpretation (default 0.05).

audience

One of c("beginner","applied","advanced").

summary_only

Logical; if TRUE, return a 3-bullet executive summary.

llm_model

Character; model name passed to your generator (default "llama3").

generate

Logical; if TRUE, call trainer_core_generate_or_return() and return prompt + response.

Examples

Run this code
set.seed(1)
tt1 <- t.test(rnorm(20, 0.1), mu = 0)              # one-sample
cat(trainer_t_test(tt1, audience = "beginner"))

x <- rnorm(18, 0); y <- rnorm(20, 0.3)
tt2 <- t.test(x, y, var.equal = FALSE)             # two-sample Welch
cat(trainer_t_test(tt2, audience = "applied", summary_only = TRUE))

Run the code above in your browser using DataLab