Skip to contents

Create a plot from the output of summariseObservationPeriod()

Usage

plotObservationPeriod(
  result,
  variableName = "Number subjects",
  plotType = "barplot",
  facet = NULL,
  colour = NULL,
  style = NULL
)

Arguments

result

A summarised_result object (output of summariseObservationPeriod()).

variableName

The variable to plot it can be: "Number subjects", "Records per person", "Duration in days" or "Days to next observation period".

plotType

The plot type, it can be: "barplot", "boxplot" or "densityplot".

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(OmopSketch)
library(dplyr, warn.conflicts = FALSE)
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 <- summariseObservationPeriod(cdm = cdm)
#> Warning: ! There are 2649 individuals not included in the person table.

tableObservationPeriod(result = result)
Summary of observation_period table
Observation period ordinal Variable name Variable level Estimate name
CDM name
GiBleed
all Number records N 5,343
Number subjects N 5,343
Subjects not in person table N (%) 2,649 (49.58%)
Records per person Mean (SD) 1.00 (0.00)
Median [Q25 - Q75] 1 [1 - 1]
Range [min to max] [1 to 1]
Duration in days Mean (SD) 14,402.00 (8,725.34)
Median [Q25 - Q75] 13,868 [7,102 - 20,956]
Range [min to max] [1 to 40,349]
Type concept id Period covering healthcare encounters N (%) 5,343 (100.00%)
Start date before birth date N (%) 0 (0.00%)
End date before start date N (%) 0 (0.00%)
Column name Observation period end date N missing data (%) 0 (0.00%)
Observation period id N missing data (%) 0 (0.00%)
N zeros (%) 0 (0.00%)
Observation period start date N missing data (%) 0 (0.00%)
Period type concept id N missing data (%) 0 (0.00%)
N zeros (%) 0 (0.00%)
Person id N missing data (%) 0 (0.00%)
N zeros (%) 0 (0.00%)
1st Number subjects N 5,343
Duration in days Mean (SD) 14,402.00 (8,725.34)
Median [Q25 - Q75] 13,868 [7,102 - 20,956]
Range [min to max] [1 to 40,349]
plotObservationPeriod( result = result, variableName = "Duration in days", plotType = "boxplot" ) cdmDisconnect(cdm = cdm) # }