Compute Date Differences and Categorize
construct_timeliness.Rd
This function takes a dataset with date variables `birth1a` and `birth1b` and computes two new variables: `datac1`, which is the difference in days between `birth1b` and `birth1a`, and `datac2`, which categorizes this difference into "current", "late", or "delayed".
Examples
df <- data.frame(
birth1a = as.Date(c('2023-01-01', '2022-01-01', '2020-01-01', '2023-06-01')),
birth1b = as.Date(c('2023-01-15', '2022-02-15', '2021-06-01', '2024-06-01'))
)
df <- construct_timeliness(df)