requireSex()
filters cohort records, keeping only records where individuals
satisfy the specified sex criteria.
Usage
requireSex(
cohort,
sex,
cohortId = NULL,
atFirst = FALSE,
name = tableName(cohort)
)
Arguments
- cohort
A cohort table in a cdm reference.
- sex
Can be "Both", "Male" or "Female".
- 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.
- atFirst
If FALSE the requirement will be applied to all records, if TRUE, it will only be required for the first entry of each subject.
- name
Name of the new cohort table created in the cdm object.
Examples
# \donttest{
library(CohortConstructor)
cdm <- mockCohortConstructor()
cdm$cohort1 |>
requireSex(sex = "Female")
#> # A tibble: 29 × 4
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> * <int> <int> <date> <date>
#> 1 1 3 2018-01-30 2018-02-28
#> 2 1 4 2016-02-19 2016-03-15
#> 3 1 6 1986-04-03 1986-04-20
#> 4 1 8 1999-02-27 2001-03-19
#> 5 1 9 2011-03-14 2012-04-05
#> 6 1 19 2002-03-19 2003-02-05
#> 7 1 20 2019-01-12 2019-01-13
#> 8 1 28 2013-07-23 2015-08-25
#> 9 1 31 2006-02-26 2006-08-15
#> 10 1 34 2000-08-26 2002-07-26
#> # ℹ 19 more rows
# }