Skip to contents

padCohortStart() Adds (or subtracts) a certain number of days to the cohort start date. Note:

  • If the days added means that cohort start would be after cohort end then the cohort entry will be dropped.

  • If subtracting day means that cohort start would be before observation period start then the cohort entry will be dropped.

Usage

padCohortStart(cohort, days, cohortId = NULL, name = tableName(cohort))

Arguments

cohort

A cohort table in a cdm reference.

days

Number of day to add to the cohort start date.

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.

Value

Cohort table

Examples

# \donttest{
library(CohortConstructor)
cdm <- mockCohortConstructor()
# add 10 days to each cohort entry
cdm$cohort1 |>
  padCohortStart(days = 10)
#> # Source:   table<main.cohort1> [9 x 4]
#> # Database: DuckDB v1.0.0 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:]
#>   cohort_definition_id subject_id cohort_start_date cohort_end_date
#>                  <int>      <int> <date>            <date>         
#> 1                    1          1 2001-06-09        2003-05-01     
#> 2                    1          1 2003-05-12        2006-06-10     
#> 3                    1          2 2000-05-14        2000-05-17     
#> 4                    1          2 2000-05-28        2001-01-23     
#> 5                    1          3 2015-02-06        2015-06-28     
#> 6                    1          4 1996-07-10        1998-11-20     
#> 7                    1          5 2012-03-30        2012-04-30     
#> 8                    1          5 2012-05-11        2012-07-24     
#> 9                    1          7 2014-03-18        2014-03-20     
# }