Learn R Programming

DrugUtilisation (version 0.8.3)

requireIsFirstDrugEntry: Restrict cohort to only the first cohort record per subject

Description

Filter the cohort table keeping only the first cohort record per subject.

Usage

requireIsFirstDrugEntry(
  cohort,
  cohortId = NULL,
  name = omopgenerics::tableName(cohort)
)

Value

The cohort table having applied the first entry requirement.

Arguments

cohort

A cohort_table object.

cohortId

A cohort definition id to restrict by. If NULL, all cohorts will be included.

name

Name of the new cohort table, it must be a length 1 character vector.

Examples

Run this code
# \donttest{
library(DrugUtilisation)
library(dplyr)

cdm <- mockDrugUtilisation()

cdm$cohort1 <- cdm$cohort1 |>
  requireIsFirstDrugEntry()

attrition(cdm$cohort1) |> glimpse()
# }

Run the code above in your browser using DataLab