Elevating Public Health Decision Making with R Packages

Kylie Ainslie

Look familiar?

What if there was a better way?

Structure your project as an R package

The Framework

  • Step 1: Organize
  • Step 2: Document
  • Step 3: Share

Let’s travel back in time

June 2021 in the Netherlands

June 2021 in the Netherlands

The Challenge

Question: Should the Netherlands extend COVID-19 vaccination to adolescents and children?

Timeline: ~2 weeks

Step #1: Organize

Typical Project

├── analysis.R
├── analysis_v2.R  
├── FINAL_analysis.R
├── analysis_FINAL_v3.R
├── data_raw.csv
├── functions_maybe.R
├── temp_script.R
└── random_test.R

Package Structure

📦 mypackage/
├── R/           # Code
├── data/        # Data  
├── man/         # Help files
└── vignettes/   # Analysis

Impact: Organization → Efficiency

  • 🔄 Models rapidly updated as new data became available
  • Analysis delivered on time
  • 💉 Directly informed health policy decisions

Step #2: Document

Separate Documents

├── analysis.R
├── methodology.docx
├── code_guide.pdf
├── final_report.pdf
├── final_report_FINAL.pdf
└── README.txt

Integrated Package

📦 mypackage/
├── R/           # Code
├── man/         # Help files
└── vignettes/   # Docs + Reports
    └── analysis.Rmd → 📊 Report.pdf
                     → 🌐 Website

Step #2: Document

Writing the help files as you write the code, so they can be documented in real time

[show screen shot of roxygen preamble and generated help file]

Step #2: Document

Vignettes

Impact: Documentation → Transparency

  • 🛡️ Policy decisions backed by transparent analysis
  • 💡 Public could understand scientific basis for decisions
  • 🤝 More public trust

Step #3: Share

Steps 1-2

+

Sharing Platform

=

Magic

Step 3: Share

  • 📁 Standard Layout → Easy team handovers
  • 📖 Full documentation → Independent verification
  • ⚙️ Complete Package → Collaboration

Impact: Sharing → Reproducibility

  • Incorporated into epidemics package transmission model library

  • 📉 Used to inform European-wide disease modeling

  • :globe_showing_europe_africa: One national analysis became international infrastructure

Your Turn!

  • Try an R package structure for your next project
  • Tons of tools and learning materials available
  • You’ll never go back to messy folders
  • (Seriously, you’ll judge your past self)
  • (And maybe judge your colleagues’ folders too)

Announcement

I’ve just submitted my first R package to CRAN!

Get in touch!

  • LinkedIn: https://www.linkedin.com/in/kylieainslie/
  • @kylieainslie.bsky.social
  • GitHub: https://github.com/kylieainslie
  • Website: https://kylieainslie.github.io/