dat <- dat |>
mutate(
time_potentially_exposed = runif(n(), 0, 45),
time_potentially_exposed = to_weeks_days(time_potentially_exposed),
time_exposed = ifelse(
time_potentially_exposed < gest_week,
time_potentially_exposed,
NA
),
week_exposed = floor(time_exposed),
ever_exposed = ifelse(!is.na(time_exposed), 1, 0),
# Set time_exposed to arbitrarily high value if never exposed
# to not have to deal with NAs in later analyses
time_exposed = ifelse(is.na(time_exposed), 1000, time_exposed),
week_exposed = ifelse(is.na(week_exposed), 1000, week_exposed)
)






