sampleCohorts()
samples an existing cohort table for a given number of
people. All records of these individuals are preserved.
Usage
sampleCohorts(cohort, n, cohortId = NULL, name = tableName(cohort))
Arguments
- cohort
A cohort table in a cdm reference.
- n
Number of people to be sampled for each included cohort.
- 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.
Examples
# \donttest{
library(CohortConstructor)
cdm <- mockCohortConstructor()
cdm$cohort2 |> sampleCohorts(cohortId = 1, n = 10)
#> # A tibble: 115 × 4
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> * <int> <int> <date> <date>
#> 1 1 76 1991-07-24 1991-10-10
#> 2 1 76 1991-10-11 1994-01-23
#> 3 1 78 1990-01-02 1992-08-01
#> 4 1 32 1991-06-27 1991-11-06
#> 5 1 46 2009-06-23 2009-08-03
#> 6 1 46 2009-08-04 2009-08-26
#> 7 1 26 1997-08-24 2011-09-15
#> 8 1 20 1992-03-31 1992-06-25
#> 9 1 5 2013-10-25 2014-03-24
#> 10 1 5 2014-03-25 2014-11-19
#> # ℹ 105 more rows
# }