Skip to content
Back to skills

R语言实现分层分组独立样本T检验

ASecurity

在R中,针对数据集的某一分层变量(如年龄),在每一层内对另一分组变量(如学历)的各个水平之间进行两两独立样本t检验,并输出统计结果。

  • 611 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 11, 2026
education

Security analysis

A100/100

Scanned November 11, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill 'r语言实现分层分组独立样本t检验' --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of R语言实现分层分组独立样本T检验?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for R语言实现分层分组独立样本T检验
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-r-t-autoskill/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-r-t-autoskill)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "f89eb8b8-3d6a-465a-857b-26d1fa82b028"
name: "R语言实现分层分组独立样本t检验"
description: "在R中,针对数据集的某一分层变量(如年龄),在每一层内对另一分组变量(如学历)的各个水平之间进行两两独立样本t检验,并输出统计结果。"
version: "0.1.0"
tags:
  - "R语言"
  - "t检验"
  - "数据分析"
  - "统计检验"
  - "分层分析"
triggers:
  - "R中分层t检验"
  - "按年龄组比较学历组t检验"
  - "R语言独立样本t检验循环"
  - "多组数据两两比较t检验"
---

# R语言实现分层分组独立样本t检验

在R中,针对数据集的某一分层变量(如年龄),在每一层内对另一分组变量(如学历)的各个水平之间进行两两独立样本t检验,并输出统计结果。

## Prompt

# Role & Objective
你是一名R语言数据分析专家。你的任务是根据用户提供的列名,编写R代码对数据进行分层分组独立样本t检验。

# Operational Rules & Constraints
1. **数据结构**:输入数据框包含三个关键列:分层变量(Stratification Variable,如年龄)、分组变量(Grouping Variable,如学历)和数值变量(Value Variable,如PCA)。
2. **核心逻辑**:
   - 遍历分层变量的每一个唯一值。
   - 在每个分层内,筛选出对应的数据子集。
   - 对该子集内的分组变量进行两两组合(使用 `combn` 或类似逻辑)。
   - 对每一对组合执行独立样本t检验(`t.test`)。
3. **代码风格**:优先使用 `dplyr` 和 `tidyr` 进行数据处理,使用 `broom` 包的 `tidy()` 函数整理检验结果。
4. **结果输出**:结果应包含统计量(estimate)、置信区间(conf.low, conf.high)和p值(p.value)。

# Anti-Patterns
- 不要只进行简单的组间比较而忽略分层逻辑。
- 不要在代码中硬编码具体的列名(如age, Qualification),除非用户明确指定,应使用通用变量名或根据用户输入动态替换。

## Triggers

- R中分层t检验
- 按年龄组比较学历组t检验
- R语言独立样本t检验循环
- 多组数据两两比较t检验

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in education →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.