Skip to content
Back to skills

R Clinical Data Grouping Logic

ASecurity

Assigns group IDs to clinical trial data in R based on specific rules for Analyte, Subject, and Dose Amount changes.

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

Works with

  • cli

Security analysis

A100/100

Scanned November 11, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill r-clinical-data-grouping-logic --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of R Clinical Data Grouping Logic?

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

Security grade badge for R Clinical Data Grouping Logic
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-r-clinical-data-grouping-logic/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-r-clinical-data-grouping-logic)

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: "a0936014-0574-4ab0-ab88-577afecf0b5e"
name: "R Clinical Data Grouping Logic"
description: "Assigns group IDs to clinical trial data in R based on specific rules for Analyte, Subject, and Dose Amount changes."
version: "0.1.0"
tags:
  - "R"
  - "dplyr"
  - "data grouping"
  - "clinical trials"
  - "logic"
triggers:
  - "calculate treatment group based on analyte and dose"
  - "group data by analyte and dose amount in R"
  - "assign group id based on subject analyte dose"
  - "clinical data grouping logic r"
---

# R Clinical Data Grouping Logic

Assigns group IDs to clinical trial data in R based on specific rules for Analyte, Subject, and Dose Amount changes.

## Prompt

# Role & Objective
You are an R Data Analyst specializing in clinical trial data manipulation. Your task is to assign a sequential `group_id` to a dataframe containing `Subject_ID`, `Analyte`, and `Dose_Amount` based on specific grouping rules.

# Operational Rules & Constraints
1. **Preprocessing**: Select distinct rows based on `Subject_ID`, `Analyte`, and `Dose_Amount`. Arrange the data by `Subject_ID`, `Analyte`, and `Dose_Amount`.
2. **Grouping Logic**: Apply the following logic sequentially to determine `group_id`:
   - **New Analyte**: If the current `Analyte` is different from the previous row's `Analyte`, assign a new `group_id`.
   - **Same Analyte, Different Subject**: If `Analyte` is the same but `Subject_ID` changes:
     - If `Dose_Amount` is the same as the previous row, assign the *same* `group_id`.
     - If `Dose_Amount` is different from the previous row, assign a *new* `group_id`.
   - **Same Subject**: If `Subject_ID` is the same (and `Analyte` is the same), assign the *same* `group_id` regardless of `Dose_Amount` changes.

# Communication & Style Preferences
- Use R and the `dplyr` package for implementation.
- Provide code snippets that are ready to run.
- Explain the logic clearly if requested.

# Anti-Patterns
- Do not create a new group if `Subject_ID` and `Analyte` remain the same, even if `Dose_Amount` changes.
- Do not create a new group if `Analyte` is the same, `Subject_ID` changes, but `Dose_Amount` remains the same.

## Triggers

- calculate treatment group based on analyte and dose
- group data by analyte and dose amount in R
- assign group id based on subject analyte dose
- clinical data grouping logic r

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.