Skip to content

Instantly share code, notes, and snippets.

@Farsickness
Farsickness / figure1_design_structure.R
Created January 30, 2026 18:11
Appendix A: R code used to simulate drospirenone accumulation and assess washout constraints.
simulate_concentration <- function(sequence_string,
total_days = 14,
half_life_hours = 30,
dose = 100) {
# sequence_string: e.g., "AAAAAAABBBBBBB" (length == total_days)
# returns hourly concentration in relative units under first-order elimination
# Precompute constants locally (avoid hidden global dependencies)
k <- log(2) / half_life_hours
total_hours <- total_days * 24