Skip to contents

[Experimental]

Usage

plotCohortCount(result, x = NULL, facet = c("cdm_name"), colour = NULL)

Arguments

result

A summarised_result object. Output of summariseCohortCount().

x

Variables to use in x axis.

facet

Columns to facet by. See options with tidyColumns(result). Formula is also allowed to specify rows and columns.

colour

Columns to color by. See options with tidyColumns(result).

Value

A ggplot.

Examples

# \donttest{
library(CohortCharacteristics)
library(PatientProfiles)
library(dplyr, warn.conflicts = FALSE)

cdm <- mockCohortCharacteristics(numberIndividuals = 100)

counts <- cdm$cohort2 |>
  addSex() |>
  addAge(ageGroup = list(c(0, 29), c(30, 59), c(60, Inf))) |>
  summariseCohortCount(strata = list("age_group", "sex", c("age_group", "sex"))) |>
  filter(variable_name == "Number subjects")
#>  summarising data
#>  summariseCharacteristics finished!

counts |>
  plotCohortCount(
    x = "sex",
    facet = cohort_name ~ age_group,
    colour = "sex"
  )


mockDisconnect(cdm)
# }