plotCohortCount: Plot the result of summariseCohortCount.

View source: R/plotCohortCount.R

plotCohortCountR Documentation

Plot the result of summariseCohortCount.

Description

[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


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")

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

mockDisconnect(cdm)



CohortCharacteristics documentation built on Oct. 1, 2024, 5:08 p.m.