Appendix D: Project Plans and Code Templates

Below is a collection of project plans and code templates referenced throughout this textbook. Rather than embedding all content here, each item is split into its own file for easier navigation and reuse.

Use these templates with sanitized plans and synthetic fixtures. Keep protected data outside the repository, do not paste individual-level records or private paths into LLM prompts, and run generated code against real data only in the approved environment.

flowchart TB
    accTitle: Appendix D template relationship map
    accDescr: A relationship map showing planning materials flowing into coding, review, refactoring, standardization, and documentation resources.
    A[Project plan examples] --> B[Coding prompt]
    B --> C[Generated R script]
    C --> D[Red teaming prompt]
    D --> E[Refactoring prompt]
    E --> F[R code template]
    F --> G[Standardized script]
    G --> H[GitHub documentation guidelines]

D.1 Project Plan – Initial Draft

A basic outline covering data ingestion, cleaning, representative record selection, and categorization. It serves as the starting point for iterative improvements.


D.2 Project Plan – Improved Version

In this iteration, the project plan is enhanced with more detailed steps for filtering, validation, and output generation. It refines the initial draft for better clarity and completeness.


D.3 Project Plan – Advanced Version

This comprehensive plan integrates additional datasets (e.g., demographics), applies race-specific BMI categorizations, and details output summary reporting. It represents a mature workflow for processing clinical EHR data.


D.4 Coding Prompt for R Script Generation

This expert-level prompt instructs an AI assistant on generating a production-quality R script using data.table and optparse. It emphasizes thorough planning, asking clarifying questions, and following best practices for modular and reproducible code.


D.5 R Code Refactoring Prompt Example

This document demonstrates how to instruct an AI assistant to reformat an existing R script to match a prescribed template’s structure and style guidelines. It emphasizes code readability and robust error handling.


D.6 R Code Template

This production-quality R script template includes metadata, dependency management, command-line argument parsing, core logic, and output saving sections. It is designed as a starting point for building robust, reproducible R scripts.


D.7 GitHub Repository Documentation Guidelines

This file provides best practices for generating a well-structured GitHub repository, including a detailed README.md, tool-specific documentation, and environment setup using the mamba (Conda) package manager.