Skip to contents

This function combines the functionalities of formatEstimateValue(), estimateName(), formatHeader(), and formatTable() into a single function specifically for <summarised_result> objects.

Usage

visOmopTable(
  result,
  estimateName = character(),
  header = character(),
  settingsColumn = character(),
  groupColumn = character(),
  rename = character(),
  type = "gt",
  hide = character(),
  columnOrder = character(),
  showMinCellCount = TRUE,
  .options = list(),
  settingsColumns = lifecycle::deprecated()
)

Arguments

result

A <summarised_result> object.

estimateName

A named list of estimate names to join, sorted by computation order. Use <...> to indicate estimate names.

header

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

  1. Column names from the split summarised result generated by splitAll()

  2. Settings specified in the settings argument

  3. group, strata, additional, variable, estimate, and/or settings to refer to all columns within these groups

  4. Any other input to create overall header labels at the specified location.

settingsColumn

A character vector with the names of settings to include in the table.

groupColumn

Columns to use as group labels. By default, the name of the new group will be the tidy* column names separated by ";". To specify a custom group name, use a named list such as: list("newGroupName" = c("variable_name", "variable_level")).

*tidy: The tidy format applied to column names replaces "_" with a space and converts to sentence case. Use rename to customize specific column names.

rename

A named vector to customize column names, e.g., c("Database name" = "cdm_name"). The function renames all column names not specified here into a tidy* format.

type

The desired format of the output table. See tableType() for allowed options.

hide

Columns to drop from the output table. By default, result_id and estimate_type are always dropped.

columnOrder

Character vector establishing the position of the columns in the formatted table. Columns in either header, groupColumn, or hide will be ignored.

showMinCellCount

If TRUE, suppressed estimates will be indicated with "<{min_cell_count}", otherwise, the default na defined in .options will be used.

.options

A named list with additional formatting options. visOmopResults::tableOptions() shows allowed arguments and their default values.

settingsColumns

[Deprecated]

Value

A tibble, gt, or flextable object.

Examples

result <- mockSummarisedResult()
result |>
  visOmopTable(
    estimateName = c("N%" = "<count> (<percentage>)",
                     "N" = "<count>",
                     "Mean (SD)" = "<mean> (<sd>)"),
    header = c("group"),
    rename = c("Database name" = "cdm_name"),
    groupColumn = strataColumns(result)
  )
Database name Variable name Variable level Estimate name
Cohort name
cohort1 cohort2
overall; overall
mock number subjects - N 9,453,343 4,814,845
age - Mean (SD) 34.94 (5.67) 87.85 (2.87)
Medications Amoxiciline N% 68,668 (60.63) 13,351 (17.30)
Ibuprofen N% 64,954 (31.30) 75,741 (17.21)
<40; Male
mock number subjects - N 7,927,355 3,961,379
age - Mean (SD) 56.63 (4.79) 90.98 (7.73)
Medications Amoxiciline N% 73,531 (11.08) 9,984 (6.49)
Ibuprofen N% 7,758 (30.88) 12,243 (92.35)
>=40; Male
mock number subjects - N 8,315,819 3,187,564
age - Mean (SD) 52.90 (5.68) 44.55 (5.75)
Medications Amoxiciline N% 46,111 (19.56) 17,139 (45.17)
Ibuprofen N% 59,965 (34.52) 19,370 (61.37)
<40; Female
mock number subjects - N 6,189,772 8,383,750
age - Mean (SD) 63.70 (2.87) 28.96 (0.22)
Medications Amoxiciline N% 66,200 (0.71) 61,718 (37.94)
Ibuprofen N% 87,901 (82.84) 31,418 (31.56)
>=40; Female
mock number subjects - N 4,437,336 2,992,035
age - Mean (SD) 35.08 (7.60) 30.33 (7.73)
Medications Amoxiciline N% 96 (94.09) 68,326 (90.93)
Ibuprofen N% 73,204 (27.40) 13,753 (80.97)
overall; Male
mock number subjects - N 9,646,256 6,160,618
age - Mean (SD) 92.42 (2.28) 91.90 (0.59)
Medications Amoxiciline N% 97,597 (6.82) 79,057 (2.99)
Ibuprofen N% 8,005 (43.08) 84,780 (90.24)
overall; Female
mock number subjects - N 1,621,987 4,621,038
age - Mean (SD) 47.40 (4.27) 93.57 (0.28)
Medications Amoxiciline N% 22,016 (13.69) 21,325 (19.48)
Ibuprofen N% 83,275 (41.69) 48,522 (12.53)
<40; overall
mock number subjects - N 1,856,538 9,392,060
age - Mean (SD) 77.81 (4.57) 67.16 (7.41)
Medications Amoxiciline N% 30,633 (33.28) 79,201 (67.95)
Ibuprofen N% 86,471 (13.43) 47,024 (56.56)
>=40; overall
mock number subjects - N 6,131,014 62,914
age - Mean (SD) 79.87 (7.10) 37.13 (5.93)
Medications Amoxiciline N% 73,157 (48.97) 59,263 (74.75)
Ibuprofen N% 71,296 (68.63) 79,105 (12.76)