Set cohort start or cohort end
Usage
padCohortDate(
cohort,
days,
cohortDate = "cohort_start_date",
indexDate = "cohort_start_date",
collapse = TRUE,
requireFullContribution = FALSE,
cohortId = NULL,
name = tableName(cohort),
.softValidation = FALSE
)
Arguments
- cohort
A cohort table in a cdm reference.
- days
Integer with the number of days to add or name of a column (that must be numeric) to add.
- cohortDate
'cohort_start_date' or 'cohort_end_date'.
- indexDate
Variable in cohort that contains the index date to add.
- collapse
Whether to collapse the overlapping records (TRUE) or drop the records that have an ongoing prior record.
- requireFullContribution
Whether to require individuals to contribute all required days. If TRUE, those individuals for which adding days would take them out of observation will be dropped. If FALSE, days will only be added up to the day when the individual leaves observation.
- cohortId
Vector identifying which cohorts to modify (cohort_definition_id or cohort_name). If NULL, all cohorts will be used; otherwise, only the specified cohorts will be modified, and the rest will remain unchanged.
- name
Name of the new cohort table created in the cdm object.
- .softValidation
Whether to perform a soft validation of consistency. If set to FALSE four additional checks will be performed: 1) a check that cohort end date is not before cohort start date, 2) a check that there are no missing values in required columns, 3) a check that cohort duration is all within observation period, and 4) that there are no overlapping cohort entries
Examples
# \donttest{
library(CohortConstructor)
cdm <- mockCohortConstructor()
cdm$cohort1 |>
padCohortDate(
cohortDate = "cohort_end_date",
indexDate = "cohort_start_date",
days = 10)
#> # A tibble: 59 × 4
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> * <int> <int> <date> <date>
#> 1 1 79 1970-03-13 1970-03-23
#> 2 1 19 1973-03-02 1973-03-12
#> 3 1 51 1978-04-26 1978-05-06
#> 4 1 70 1978-12-14 1978-12-24
#> 5 1 48 1979-06-15 1979-06-25
#> 6 1 69 1980-03-26 1980-04-05
#> 7 1 37 1982-05-14 1982-05-24
#> 8 1 35 1982-12-23 1983-01-02
#> 9 1 29 1984-07-25 1984-08-04
#> 10 1 60 1985-10-23 1985-11-02
#> # ℹ 49 more rows
# }