Restrict cohort to only the first cohort record per subject
Source:R/require.R
requireIsFirstDrugEntry.Rd
Filter the cohort table keeping only the first cohort record per subject.
Usage
requireIsFirstDrugEntry(
cohort,
cohortId = NULL,
name = omopgenerics::tableName(cohort)
)
Examples
# \donttest{
library(DrugUtilisation)
library(dplyr)
cdm <- mockDrugUtilisation()
cdm$cohort1 <- cdm$cohort1 |>
requireIsFirstDrugEntry()
attrition(cdm$cohort1) |> glimpse()
#> Rows: 6
#> Columns: 7
#> $ cohort_definition_id <int> 1, 1, 2, 2, 3, 3
#> $ number_records <int> 2, 2, 3, 3, 5, 5
#> $ number_subjects <int> 2, 2, 3, 3, 5, 5
#> $ reason_id <int> 1, 2, 1, 2, 1, 2
#> $ reason <chr> "Initial qualifying events", "require is the firs…
#> $ excluded_records <int> 0, 0, 0, 0, 0, 0
#> $ excluded_subjects <int> 0, 0, 0, 0, 0, 0
# }