Skip to contents

Update the cohort attrition table with new counts and a reason for attrition.

Usage

recordCohortAttrition(cohort, reason, cohortId = NULL)

record_cohort_attrition(cohort, reason, cohortId = NULL)

Arguments

cohort

A generated cohort set

reason

The reason for attrition as a character string

cohortId

Cohort definition id of the cohort you want to update the attrition

Value

The cohort object with the attributes created or updated.

[Experimental]

Examples

if (FALSE) { # \dontrun{
library(CDMConnector)
library(dplyr)

con <- DBI::dbConnect(duckdb::duckdb(), eunomia_dir())
cdm <- cdm_from_con(con = con, cdm_schema = "main", write_schema = "main")
cdm <- generateConceptCohortSet(
  cdm = cdm, conceptSet = list(pharyngitis = 4112343), name = "new_cohort"
)

settings(cdm$new_cohort)
cohortCount(cdm$new_cohort)
cohortAttrition(cdm$new_cohort)

cdm$new_cohort <- cdm$new_cohort %>%
  filter(cohort_start_date >= as.Date("2010-01-01"))

cdm$new_cohort <- updateCohortAttributes(
  cohort = cdm$new_cohort, reason = "Only events after 2010"
)

settings(cdm$new_cohort)
cohortCount(cdm$new_cohort)
cohortAttrition(cdm$new_cohort)
} # }