Skip to contents

Create a visual table from a summariseObservationPeriod() result

Usage

tableObservationPeriod(
  result,
  header = "cdm_name",
  hide = omopgenerics::settingsColumns(result),
  groupColumn = omopgenerics::strataColumns(result),
  type = NULL,
  style = NULL
)

Arguments

result

A summarised_result object (output of summariseObservationPeriod()).

header

A vector specifying the elements to include in the header. The order of elements matters, with the first being the topmost header.

hide

Columns to drop from the output table.

groupColumn

Columns to use as group labels, to see options use visOmopResults::tableColumns(result).

type

Character string specifying the desired output table format. See visOmopResults::tableType() for supported table types. If type = NULL, global options (set via visOmopResults::setGlobalTableOptions()) will be used if available; otherwise, a default 'gt' table is created.

style

Defines the visual formatting of the table. This argument can be provided in one of the following ways:

  1. Pre-defined style: Use the name of a built-in style (e.g., "darwin"). See visOmopResults::tableStyle() for available options.

  2. YAML file path: Provide the path to an existing .yml file defining a new style.

  3. List of custome R code: Supply a block of custom R code or a named list describing styles for each table section. This code must be specific to the selected table type.

If style = NULL, the function will use global options (seevisOmopResults::setGlobalTableOptions()) or a _brand.yml file (if found); otherwise, the default style is applied.

Value

A formatted table visualisation.

Examples

# \donttest{
library(OmopSketch)
library(dplyr, warn.conflicts = FALSE)
library(omock)

cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb")
#>  Loading bundled GiBleed tables from package data.
#>  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 Is required Estimate name
Data source
GiBleed
all Number records overall N 5,343
Number subjects overall N 5,343
Subjects not in person table overall N (%) 2,649 (49.58%)
Records per person overall Mean (SD) 1.00 (0.00)
Median [Q25 - Q75] 1 [1 - 1]
Range [min to max] [1 to 1]
Duration in days overall Mean (SD) 14,402.00 (8,725.34)
Median [Q25 - Q75] 13,868.00 [7,102.50 - 20,955.50]
Range [min to max] [1.00 to 40,349.00]
Type concept id Period covering healthcare encounters overall N (%) 5,343 (100.00%)
Start date before birth date overall N (%) 0 (0.00%)
End date before start date overall N (%) 0 (0.00%)
Column name Observation period end date TRUE N missing data (%) 0 (0.00%)
Observation period id TRUE N missing data (%) 0 (0.00%)
N zeros (%) 0 (0.00%)
Observation period start date TRUE N missing data (%) 0 (0.00%)
Period type concept id TRUE N missing data (%) 0 (0.00%)
N zeros (%) 0 (0.00%)
Person id TRUE N missing data (%) 0 (0.00%)
N zeros (%) 0 (0.00%)
1st Number subjects overall N 5,343
Duration in days overall Mean (SD) 14,402.00 (8,725.34)
Median [Q25 - Q75] 13,868.00 [7,102.50 - 20,955.50]
Range [min to max] [1.00 to 40,349.00]
plotObservationPeriod( result = result, variableName = "Duration in days", plotType = "boxplot" ) cdmDisconnect(cdm = cdm) # }