Skip to contents

Plot summariseMeasurementTiming results.

Usage

plotMeasurementSummary(
  result,
  y = "time",
  plotType = "boxplot",
  timeScale = "days",
  facet = visOmopResults::strataColumns(result),
  colour = c("cdm_name", "codelist_name"),
  style = NULL
)

Arguments

result

A summarised_result object.

y

Variable to plot on y axis, it can be "time" or "measurements_per_subject".

plotType

Type of plot, either "boxplot", "barplot", or "densityplot".

timeScale

Time scale to show, it can be "days" or "years".

facet

Columns to facet by. See options with `visOmopResults::plotColumns(result)`. Formula input is also allowed to specify rows and columns.

colour

Columns to color by. See options with `visOmopResults::plotColumns(result)`.

style

Pre-defined style to apply: "default" or "darwin" - the latter just for gt and flextable. If NULL the "default" style is used.

Value

A ggplot.

Examples

# \donttest{
library(MeasurementDiagnostics)
library(dplyr)
#> 
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#> 
#>     filter, lag
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, setequal, union

cdm <- mockMeasurementDiagnostics()

result <- summariseMeasurementUse(
  cdm = cdm,
  codes = list("test_codelist" = c(3001467L, 45875977L))
)
#> → Sampling measurement table to 20000 subjects
#> → Getting measurement records based on 2 concepts.
#> → Subsetting records to the subjects and timing of interest.
#> → Getting time between records per person.
#> Summarising timings
#>  The following estimates will be computed:
#>  time: min, q25, median, q75, max, density
#> ! Table is collected to memory as not all requested estimates are supported on
#>   the database side
#> → Start summary of data, at 2026-01-15 11:40:36.925248
#>  Summary finished, at 2026-01-15 11:40:37.052281
#> → Getting measurements per subject.
#> Summarising subjects
#>  The following estimates will be computed:
#>  measurements_per_subject: min, q25, median, q75, max, density
#> ! Table is collected to memory as not all requested estimates are supported on
#>   the database side
#> → Start summary of data, at 2026-01-15 11:40:37.568016
#>  Summary finished, at 2026-01-15 11:40:37.683647
#> → Summarising results - value as number.
#> Summarising value as number
#>  The following estimates will be computed:
#>  value_as_number: min, q01, q05, q25, median, q75, q95, q99, max,
#>   count_missing, percentage_missing, density
#> ! Table is collected to memory as not all requested estimates are supported on
#>   the database side
#> → Start summary of data, at 2026-01-15 11:40:38.89385
#>  Summary finished, at 2026-01-15 11:40:39.187828
#> → Summarising results - value as concept.
#> Summarising value as number
#>  The following estimates will be computed:
#>  value_as_concept_id: count, percentage
#> → Start summary of data, at 2026-01-15 11:40:39.841426
#>  Summary finished, at 2026-01-15 11:40:40.009132
#> → Binding all diagnostic results.

result |>
  filter(variable_name == "time") |>
  plotMeasurementSummary()
#> Ignoring unknown labels:
#>  fill : "Cdm name and Codelist name"


CDMConnector::cdmDisconnect(cdm)
# }