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(nPerson = 100)
cdm$cohort2 |> sampleCohorts(cohortId = 1, n = 10)
#> # Source: table<cohort2> [?? x 4]
#> # Database: DuckDB v1.2.1 [unknown@Linux 6.8.0-1021-azure:R 4.4.3/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 1 9 2011-12-20 2011-12-20
#> 2 1 9 2011-12-21 2011-12-29
#> 3 1 9 2011-12-30 2012-04-02
#> 4 1 16 2005-12-28 2008-06-11
#> 5 1 17 2009-06-18 2013-02-01
#> 6 1 23 2000-10-08 2001-06-04
#> 7 1 23 2001-06-05 2003-08-26
#> 8 1 26 1984-05-16 1993-10-28
#> 9 1 37 1999-02-05 2002-12-01
#> 10 1 52 1991-10-19 1992-12-11
#> # ℹ more rows
# }