T-Test Analysis
# FALLBACK LOGIC
if(!exists("raw_data")) {
# Sample Data if run independently
raw_data <- data.frame(
gender = sample(c("Male", "Female"), 50, replace = TRUE),
anxiety_score = rnorm(50, 20, 5)
)
}
# 1. Run T-Test
# We use standard base R t.test for simplicity, formatted with a tidy approach if broom is available
# For this course consistency, we likely want straightforward output
t_result <- t.test(anxiety_score ~ gender, data = raw_data)
# 2. Print Result
print(t_result)
Welch Two Sample t-test
data: anxiety_score by gender
t = -0.98744, df = 24.148, p-value = 0.3332
alternative hypothesis: true difference in means between group Female and group Male is not equal to 0
95 percent confidence interval:
-3.975957 1.402091
sample estimates:
mean in group Female mean in group Male
19.61610 20.90303
# 3. APA Style Reporting (Optional automated text)
# "There was a significant difference between groups (t(df) = x.xx, p = .xxx)..."