R for Public Health — Essential Templates Bundle
8 production-ready R scripts for epidemiologists, public health officers, and health researchers. Open the file, swap in your data, run.
Public health work moves fast. Outbreak investigations don't wait for you to write code from scratch, surveillance reports are due every Monday morning, and your dissertation analysis needs to be reproducible and properly formatted.
This bundle gives you four of the most commonly needed analyses in public health — already written, thoroughly commented, and ready to run on your real data today.
Every template comes as both a standalone .R script for users who just need results, and
a full .Rmd report that knits to a polished HTML or PDF document you can hand directly
to a supervisor, attach to a field report, or submit alongside a manuscript. No custom coding
required. No hunting Stack Overflow for the right ggplot2 theme. Just set your column names, point
the script at your data, and run.
What's in the bundle:
- Epidemic Curve Generator — Produce a publication-ready epi curve by day, week, or month, with confirmed, probable, and suspected cases colour-coded. Includes a full outbreak summary report with age, sex, and classification breakdowns.
- Survey Data Cleaning Script — Automatically fix the 8 most common problems in ODK, KoboToolbox, and DHIS2 exports: duplicate IDs, bad dates, out-of-range ages, inconsistent sex entries, messy district names, and more. Every step is logged and flagged records are saved separately for review.
- Logistic Regression Risk Factor Analysis — Run crude and adjusted odds ratios, generate a colour-coded forest plot, and assess model fit with AUC, ROC curve, and Nagelkerke R² — all in one script. Built for case-control studies, outbreak investigations, and cross-sectional surveys.
- Disease Surveillance Summary Report — Automate your weekly or monthly surveillance reporting. Alert thresholds, moving average trend lines, district breakdowns, and CFR trends — outputs to Excel, PNG plots, and a fully written HTML or PDF report.
Who this is for:
This bundle was built specifically for people working in public health who use R — or are learning to. Whether you're a field epidemiologist writing up an outbreak investigation, a public health officer producing weekly district reports, an MPH student working on your dissertation, or a researcher cleaning survey data before analysis, these templates will save you hours every time you use them.
They work with the data formats you already have — CSV and Excel exports from ODK, KoboToolbox, DHIS2, Epi Info, and any standard surveillance line list. Every script includes built-in sample data so you can run it immediately and see exactly what the output looks like before you touch your own data.