Create step-by-step tutorials and educational content from R code. This command uses the **r-tutorial-engineer** agent to transform code into progressive learning experiences.
Transforms R code into step-by-step tutorials with exercises and solutions in multiple formats.
/plugin marketplace add choxos/BiostatAgent/plugin install choxos-r-tidy-modeling-plugins-r-tidy-modeling@choxos/BiostatAgentCreate step-by-step tutorials and educational content from R code. This command uses the r-tutorial-engineer agent to transform code into progressive learning experiences.
/r-tutorial-create [source] [topic] [format] [level]
source: Path to R code/script to document, or topic keywordtopic: Tutorial topic/titleformat: One of rmd, qmd, learnr, html (default: qmd)level: One of beginner, intermediate, advanced (default: intermediate)Code Walkthrough
Concept Tutorial
How-To Guide
Cookbook
rmd: R Markdown document
qmd: Quarto document
learnr: Interactive tutorial
html: Static HTML
output/
└── tutorials/
├── tutorial_name/
│ ├── tutorial.qmd # Main tutorial
│ ├── exercises/
│ │ ├── exercise_01.R # Practice files
│ │ └── exercise_02.R
│ ├── solutions/
│ │ ├── solution_01.R # Answer keys
│ │ └── solution_02.R
│ └── data/ # Example data
└── tutorial_name_learnr/ # If learnr format
└── tutorial.Rmd
/r-tutorial-create R/analysis.R "Survival Analysis Basics" learnr beginner
This creates a beginner-level learnr tutorial teaching survival analysis based on the code in R/analysis.R.
# Tutorial Title
## Learning Objectives
By the end of this tutorial, you will be able to:
- Objective 1
- Objective 2
- Objective 3
## Prerequisites
Before starting, you should:
- Have R installed
- Be familiar with basic R syntax
- Have packages X, Y, Z installed
## Introduction
Overview and motivation...
## Section 1: [Topic]
### Concept Explanation
[Theory and background]
### Example Code
[Annotated code with output]
### Try It Yourself
[Exercise prompt]
<details>
<summary>Solution</summary>
[Solution code]
</details>
## Section 2: [Topic]
...
## Summary
Key takeaways:
- Point 1
- Point 2
- Point 3
## Next Steps
To continue learning:
- Tutorial link 1
- Tutorial link 2
---
title: "Tutorial Title"
output: learnr::tutorial
runtime: shiny_prerendered
---
```{r setup, include=FALSE}
library(learnr)
library(tidyverse)
knitr::opts_chunk$set(echo = FALSE)
Welcome text...
Concept explanation...
Write code to...
# Your code here
# Try using the function...
# Complete solution
quiz(
question("Question text?",
answer("Wrong answer"),
answer("Correct answer", correct = TRUE),
answer("Another wrong answer")
)
)
## Content Features
### Code Annotations
- Line-by-line explanations
- Output interpretation
- Why certain approaches are used
- Common variations
### Exercises
- Fill-in-the-blank code
- Debug exercises
- Extend existing code
- Write from scratch
### Progressive Difficulty
- Start with simple examples
- Add complexity gradually
- Challenge problems at end
- Extension ideas for advanced learners
### Visual Aids
- Diagrams for concepts
- Flowcharts for processes
- Output screenshots
- Comparison tables
## Notes
- Original code is never modified
- All tutorials go to output/tutorials/
- Includes standalone exercise files
- Solutions provided separately
- Example data included when needed