plotCharacteristics {CohortCharacteristics}R Documentation

Create a ggplot from the output of summariseCharacteristics. 'r lifecycle::badge("experimental")'

Description

Create a ggplot from the output of summariseCharacteristics. 'r lifecycle::badge("experimental")'

Usage

plotCharacteristics(
  data,
  x = "variable_name",
  plotStyle = "barplot",
  facet = NULL,
  colour = NULL,
  colourName = NULL,
  .options = list()
)

Arguments

data

output of summariseCharacteristics.

x

what to plot on x axis, default as variable_name column. Has to be a column in data.

plotStyle

Now allows boxplot or barplot only.

facet

Variables to facet by

colour

column in data to color by.

colourName

Colour legend name

.options

Additional plotting options.

Value

A ggplot.

Examples


library(CohortCharacteristics)
library(dplyr)

cdm <- mockCohortCharacteristics()

results <- summariseCharacteristics(
  cohort = cdm$cohort1,
  ageGroup = list(c(0, 19), c(20, 39), c(40, 59), c(60, 79), c(80, 150)),
  tableIntersectCount = list(
    tableName = "visit_occurrence", window = c(-365, -1)
  ),
  cohortIntersectFlag = list(
    targetCohortTable = "cohort2", window = c(-365, -1)
  )
)

results |>
  filter(
    variable_name == "Cohort2 flag -365 to -1",
    estimate_name == "percentage"
  ) |>
  plotCharacteristics(
    plotStyle = "barplot",
    colour = "variable_level",
    x = "variable_level",
    facet = c(
      "cdm_name",
      "group_level",
      "strata_level"
    )
  )

mockDisconnect(cdm = cdm)


[Package CohortCharacteristics version 0.2.2 Index]