summariseCohortCodeUse: Summarise code use among a cohort in the cdm reference

View source: R/summariseCodeUse.R

summariseCohortCodeUseR Documentation

Summarise code use among a cohort in the cdm reference

Description

Summarise code use among a cohort in the cdm reference

Usage

summariseCohortCodeUse(
  x,
  cdm,
  cohortTable,
  cohortId = NULL,
  timing = "any",
  countBy = c("record", "person"),
  byConcept = TRUE,
  byYear = FALSE,
  bySex = FALSE,
  ageGroup = NULL,
  minCellCount = 5
)

Arguments

x

Vector of concept IDs

cdm

cdm_reference via CDMConnector::cdm_from_con()

cohortTable

A cohort table from the cdm reference.

cohortId

A vector of cohort IDs to include

timing

When to assess the code use relative cohort dates. This can be "any"(code use any time by individuals in the cohort) or "entry" (code use on individuals' cohort start date).

countBy

Either "record" for record-level counts or "person" for person-level counts

byConcept

TRUE or FALSE. If TRUE code use will be summarised by

byYear

TRUE or FALSE. If TRUE code use will be summarised by year.

bySex

TRUE or FALSE. If TRUE code use will be summarised by sex.

ageGroup

If not NULL, a list of ageGroup vectors of length two.

minCellCount

The minimum number of counts to reported, below which results will be suppressed. If 0, all results will be reported.

Value

A tibble with results overall and, if specified, by strata

Examples

## Not run: 
con <- DBI::dbConnect(duckdb::duckdb(),
                      dbdir = CDMConnector::eunomia_dir())
cdm <- CDMConnector::cdm_from_con(con,
                                  cdm_schem = "main",
                                  write_schema = "main")
cdm <- CDMConnector::generateConceptCohortSet(cdm = cdm,
conceptSet = list(a = 260139,
                  b = 1127433),
                  name = "cohorts",
                  end = "observation_period_end_date",
                  overwrite = TRUE)

results_cohort_mult <-
summariseCohortCodeUse(list(cs = c(260139,19133873)),
                      cdm = cdm,
                      cohortTable = "cohorts",
                      timing = "entry",
                      minCellCount = 0)

results_cohort_mult
CDMConnector::cdmDisconnect(cdm)

## End(Not run)

oxford-pharmacoepi/CodelistGenerator documentation built on April 12, 2024, 9:30 a.m.