Learn R Programming

DrugUtilisation (version 0.8.3)

plotDrugUtilisation: Plot the results of summariseDrugUtilisation

Description

Plot the results of summariseDrugUtilisation

Usage

plotDrugUtilisation(
  result,
  variable = "number exposures",
  plotType = "barplot",
  facet = strataColumns(result),
  colour = "cohort_name"
)

Value

A ggplot2 object.

Arguments

result

A summarised_result object.

variable

Variable to plot. See unique(result$variable_name) for options.

plotType

Must be a choice between: 'scatterplot', 'barplot', 'densityplot', and 'boxplot'.

facet

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

colour

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

Examples

Run this code
# \donttest{
cdm <- mockDrugUtilisation(numberIndividuals = 100)
codes <- list(aceta = c(1125315, 1125360, 2905077, 43135274))
cdm <- generateDrugUtilisationCohortSet(
  cdm = cdm,
  name = "cohort",
  conceptSet = codes
)

result <- cdm$cohort |>
  PatientProfiles::addSex() |>
  summariseDrugUtilisation(
    strata = "sex",
    ingredientConceptId = 1125315,
    estimates = c("min", "q25", "median", "q75", "max", "density")
  )

result |>
  dplyr::filter(estimate_name == "median") |>
  plotDrugUtilisation(
    variable = "days prescribed",
    plotType = "barplot"
  )

result |>
  plotDrugUtilisation(
    variable = "days exposed",
    facet = cohort_name ~ cdm_name,
    colour = "sex",
    plotType = "boxplot"
  )

result |>
  plotDrugUtilisation(
    variable = "cumulative dose milligram",
    plotType = "densityplot",
    facet = "cohort_name",
    colour = "sex"
  )

mockDisconnect(cdm)
# }

Run the code above in your browser using DataLab