Skip to contents

Create a ggplot2 plot from the output of summariseTrend()

Usage

plotTrend(result, output = NULL, facet = "type", colour = NULL, style = NULL)

Arguments

result

A summarised_result object (output of summariseTrend()).

output

The output to plot. Accepted values are: "record", "person", "person-days", "age", and "sex". If not specified, the function will default to:

  • the only available output if there is just one in the results, or

  • "record" if multiple outputs are present.

facet

Columns to face by. Formula format can be provided. See possible columns to face by with: visOmopResults::tidyColumns().

colour

Columns to colour by. See possible columns to colour by with: visOmopResults::tidyColumns().

style

Visual theme to apply. Character, or NULL. If a character, this may be either the name of a built-in style (see visOmopResults::plotStyle()), or a path to a .yml file that defines a custom style. If NULL, the function will use the explicit default style, unless a global style option is set (see visOmopResults::setGlobalPlotOptions()) or a _brand.yml file is present (in that order).

Value

A plot visualisation.

Examples

# \donttest{
library(dplyr)
library(OmopSketch)
library(omock)

cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb")
#>  Reading GiBleed tables.
#>  Adding drug_strength table.
#>  Creating local <cdm_reference> object.
#>  Inserting <cdm_reference> into duckdb.

result <- summariseTrend(cdm,
  episode = "observation_period",
  output = c("person-days", "record"),
  interval = "years",
  ageGroup = list("<=40" = c(0, 40), ">40" = c(41, Inf)),
  sex = TRUE
)

plotTrend(
  result = result,
  output = "record",
  colour = "sex",
  facet = "age_group"
)


cdmDisconnect(cdm = cdm)
# }