Add attrition reason to a cohort_table object
Source:R/generateCohortSet.R
recordCohortAttrition.Rd
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)
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)
} # }