➡️
Structure your project as an R package
Should the Netherlands extend COVID-19 vaccination to adolescents and children?
❌ Typical Project
myproject/ ├── analysis.R ├── analysis_FINAL.R ├── analysis_FINAL_v2.R ├── code_guide.pdf ├── data_raw.csv ├── final_report.pdf ├── final_report_FINAL.pdf ├── functions.R ├── methodology.docx └── more_functions.R
✅ Package Structure
📦 mypackage/ ├── R/ # Code ├── inst/extdata/ # Data + Scripts ├── man/ # Help files └── vignettes/ # Analysis
❌ Typical Project
myproject/ ├── analysis.R ├── analysis_FINAL.R ├── analysis_FINAL_v2.R ├── code_guide.pdf ├── data_raw.csv ├── final_report.pdf ├── final_report_FINAL.pdf ├── functions.R ├── methodology.docx └── more_functions.R
✅ Package Structure
📦 mypackage/ ├── R/ # Code ├── functions.R └── more_functions.R ├── inst/extdata/ # Data + Scripts ├── man/ # Help files └── vignettes/ # Analysis
❌ Typical Project
myproject/ ├── analysis.R ├── analysis_FINAL.R ├── analysis_FINAL_v2.R ├── code_guide.pdf ├── data_raw.csv ├── final_report.pdf ├── final_report_FINAL.pdf ├── functions.R ├── methodology.docx └── more_functions.R
✅ Package Structure
📦 mypackage/ ├── R/ # Code ├── inst/extdata/ # Data + Scripts ├── analysis.R ├── analysis_FINAL.R ├── analysis_FINAL_v2.R └── data_raw.csv ├── man/ # Help files └── vignettes/ # Analysis
❌ Typical Project
myproject/ ├── analysis.R ├── analysis_FINAL.R ├── analysis_FINAL_v2.R ├── code_guide.pdf ├── data_raw.csv ├── final_report.pdf ├── final_report_FINAL.pdf ├── functions.R ├── methodology.docx └── more_functions.R
✅ Package Structure
📦 mypackage/ ├── R/ # Code ├── inst/extdata/ # Data + Scripts ├── man/ # Help files └── vignettes/ # Analysis ├── code_guide.Rmd ├── methodology.Rmd └── report.Rmd
❌ Separate Documents
myproject/ ├── analysis.R ├── analysis_FINAL.R ├── analysis_FINAL_v2.R ├── code_guide.pdf ├── data_raw.csv ├── final_report.pdf ├── final_report_FINAL.pdf ├── functions.R ├── methodology.docx └── more_functions.R
✅ Documentation lives WITH the code
📦 mypackage/ ├── R/ ├── man/ # Help files ├── hello_world.Rd ├── do_something.Rd └── busy_busy_busy.Rd └── vignettes/ # Docs + Reports ├── code_guide.Rmd ├── methodology.Rmd └── report.Rmd
#' Calculate Required Coffee for Debugging Session
#'
#' @param error_messages Integer. Number of different error messages
#' @param browser_tabs Integer. Troubleshooting browser tabs currently open
#' @param hours_stuck Numeric. Hours spent on current bug
#'
#' @return Integer. Recommended cups of coffee (max 3 for your health)
#'
#' @examples
#' coffee_for_debugging(1, 2, 0.5)
#'
#' @author Caffeinated Coder
#'
coffee_for_debugging <- function(error_messages,browser_tabs, hours_stuck){
coffee_needed <- error_messages + (browser_tabs * 0.2) + hours_stuck
result <- min(ceiling(coffee_needed), 3) # Cap at 3 cups
if (result >= 3) {
message("Maybe try rubber duck debugging instead?")
}
return(result)
}
❌ Separate Documents
myproject/ ├── analysis.R ├── analysis_FINAL.R ├── analysis_FINAL_v2.R ├── code_guide.pdf ├── data_raw.csv ├── final_report.pdf ├── final_report_FINAL.pdf ├── functions.R ├── methodology.docx └── more_functions.R
✅ Documentation lives WITH the code
📦 mypackage/ ├── R/ ├── man/ # Help files ├── hello_world.Rd ├── do_something.Rd └── busy_busy_busy.Rd └── vignettes/ # Docs + Reports ├──code_guide.Rmd├── methodology.Rmd └── report.Rmd
❌ Separate Documents
myproject/ ├── analysis.R ├── analysis_FINAL.R ├── analysis_FINAL_v2.R ├── code_guide.pdf ├── data_raw.csv ├── final_report.pdf ├── final_report_FINAL.pdf ├── functions.R ├── methodology.docx └── more_functions.R
✅ Documentation lives WITH the code
📦 mypackage/ ├── R/ ├── man/ # Help files ├── hello_world.Rd ├── do_something.Rd └── busy_busy_busy.Rd └── vignettes/ # Docs + Reports ├──code_guide.Rmd├──methodology.Rmd└── report.Rmd
Incorporated into
epidemics
package transmission model library
📉 Used to inform European-wide disease modeling
🌍 One national analysis became international infrastructure
I’ve just had my first R package accepted to CRAN!
linkedin.com/in/kylieainslie
@kylieainslie.bsky.social
github.com/kylieainslie
kylieainslie.github.io
posit::conf(2025) | 18 September 2025 | Atlanta, GA