Skip to contents

Summarise characteristics of cohorts in a cohort table

Usage

summariseCharacteristics(
  cohort,
  cohortId = NULL,
  strata = list(),
  counts = TRUE,
  demographics = TRUE,
  ageGroup = NULL,
  tableIntersectFlag = list(),
  tableIntersectCount = list(),
  tableIntersectDate = list(),
  tableIntersectDays = list(),
  cohortIntersectFlag = list(),
  cohortIntersectCount = list(),
  cohortIntersectDate = list(),
  cohortIntersectDays = list(),
  conceptIntersectFlag = list(),
  conceptIntersectCount = list(),
  conceptIntersectDate = list(),
  conceptIntersectDays = list(),
  otherVariables = character(),
  otherVariablesEstimates = c("min", "q25", "median", "q75", "max", "count",
    "percentage")
)

Arguments

cohort

A cohort table in the cdm.

cohortId

Vector of cohort definition ids to include. If NULL all cohort will be selected.

strata

A list of variables to stratify results. These variables must have been added as additional columns in the cohort table.

counts

TRUE or FALSE. If TRUE, record and person counts will be produced.

demographics

TRUE or FALSE. If TRUE, patient demographics (cohort start date, cohort end date, age, sex, prior observation, and future observation will be summarised).

ageGroup

A list of age groups to stratify results by.

tableIntersectFlag

A list of arguments that uses PatientProfiles::addTableIntersectFlag() to add variables to summarise.

tableIntersectCount

A list of arguments that uses PatientProfiles::addTableIntersectCount() to add variables to summarise.

tableIntersectDate

A list of arguments that uses PatientProfiles::addTableIntersectDate() to add variables to summarise.

tableIntersectDays

A list of arguments that uses PatientProfiles::addTableIntersectDays() to add variables to summarise.

cohortIntersectFlag

A list of arguments that uses PatientProfiles::addCohortIntersectFlag() to add variables to summarise.

cohortIntersectCount

A list of arguments that uses PatientProfiles::addCohortIntersectCount() to add variables to summarise.

cohortIntersectDate

A list of arguments that uses PatientProfiles::addCohortIntersectDate() to add variables to summarise.

cohortIntersectDays

A list of arguments that uses PatientProfiles::addCohortIntersectDays() to add variables to summarise.

conceptIntersectFlag

A list of arguments that uses PatientProfiles::addConceptIntersectFlag() to add variables to summarise.

conceptIntersectCount

A list of arguments that uses PatientProfiles::addConceptIntersectCount() to add variables to summarise.

conceptIntersectDate

A list of arguments that uses PatientProfiles::addConceptIntersectDate() to add variables to summarise.

conceptIntersectDays

A list of arguments that uses PatientProfiles::addConceptIntersectDays() to add variables to summarise.

otherVariables

Other variables contained in cohort that you want to be summarised.

otherVariablesEstimates

Name of the estimates for the otherVariables columns.

Value

A summary of the characteristics of the cohorts in the cohort table.

Examples

# \donttest{
library(dplyr)
library(CohortCharacteristics)
library(PatientProfiles)

cdm <- mockCohortCharacteristics()
#> ! cohort columns will be reordered to match the expected order:
#>   cohort_definition_id, subject_id, cohort_start_date, and cohort_end_date.
#> ! cohort columns will be reordered to match the expected order:
#>   cohort_definition_id, subject_id, cohort_start_date, and cohort_end_date.
cdm$cohort1 |>
  addSex() |>
  addAge(
    ageGroup = list(c(0, 40), c(41, 150))
  ) |>
  summariseCharacteristics(
    strata = list("sex", "age_group"),
    cohortIntersectFlag = list (
      "Cohort 2 Flag" = list(
        targetCohortTable = "cohort2",
        window = c(-365, 0)
      )
    ),
    cohortIntersectCount = list (
      "Cohort 2 Count" = list(
        targetCohortTable = "cohort2",
        window = c(-365, 0)
      )
    )
  ) |>
  glimpse()
#>  adding demographics columns
#>  adding cohortIntersectFlag 1/1
#>  adding cohortIntersectCount 1/1
#>  summarising data
#>  summariseCharacteristics finished!
#> Rows: 750
#> Columns: 13
#> $ result_id        <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
#> $ cdm_name         <chr> "PP_MOCK", "PP_MOCK", "PP_MOCK", "PP_MOCK", "PP_MOCK"…
#> $ group_name       <chr> "cohort_name", "cohort_name", "cohort_name", "cohort_…
#> $ group_level      <chr> "cohort_2", "cohort_3", "cohort_1", "cohort_2", "coho…
#> $ strata_name      <chr> "overall", "overall", "overall", "overall", "overall"…
#> $ strata_level     <chr> "overall", "overall", "overall", "overall", "overall"…
#> $ variable_name    <chr> "Number records", "Number records", "Number records",…
#> $ variable_level   <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
#> $ estimate_name    <chr> "count", "count", "count", "count", "count", "count",…
#> $ estimate_type    <chr> "integer", "integer", "integer", "integer", "integer"…
#> $ estimate_value   <chr> "7", "2", "1", "7", "2", "1", "1942-03-21", "2021-10-…
#> $ additional_name  <chr> "overall", "overall", "overall", "overall", "overall"…
#> $ additional_level <chr> "overall", "overall", "overall", "overall", "overall"…

mockDisconnect(cdm = cdm)
# }