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(),
  settingsColumns = character(),
  groupColumn = character(),
  rename = character(),
  type = "gt",
  hide = character(),
  showMinCellCount = TRUE,
  .options = list(),
  split = lifecycle::deprecated(),
  excludeColumns = lifecycle::deprecated(),
  formatEstimateName = lifecycle::deprecated(),
  renameColumns = 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.

settingsColumns

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.

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.

split

[Deprecated]

excludeColumns

[Deprecated]

formatEstimateName

[Deprecated]

renameColumns

[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)
  )
#> ! Results have not been suppressed.
Database name Variable name Variable level Estimate name Cohort name
cohort1 cohort2
overall; overall
mock number subjects - N 3,757,580 6,686,055
age - Mean (SD) 39.22 (6.09) 73.13 (1.25)
Medications Amoxiciline N% 20,595 (80.69) 10,504 (84.46)
Ibuprofen N% 14,800 (60.58) 36,579 (70.03)
<40; Male
mock number subjects - N 1,368,529 7,204,168
age - Mean (SD) 84.49 (6.28) 17.59 (9.18)
Medications Amoxiciline N% 80,943 (82.04) 34,921 (45.10)
Ibuprofen N% 33,806 (68.42) 73,651 (59.73)
>=40; Male
mock number subjects - N 986,021 5,419,602
age - Mean (SD) 88.51 (3.45) 89.05 (3.93)
Medications Amoxiciline N% 70,153 (60.69) 15,005 (85.40)
Ibuprofen N% 95,087 (70.11) 64,000 (21.30)
<40; Female
mock number subjects - N 6,423,973 3,933,305
age - Mean (SD) 73.61 (0.72) 92.42 (0.70)
Medications Amoxiciline N% 77,060 (16.22) 77,466 (95.12)
Ibuprofen N% 31,908 (92.18) 43,092 (62.89)
>=40; Female
mock number subjects - N 8,174,897 3,998,490
age - Mean (SD) 64.33 (6.00) 56.26 (6.76)
Medications Amoxiciline N% 41,081 (73.67) 48,826 (47.15)
Ibuprofen N% 13,645 (75.40) 51,922 (59.68)
overall; Male
mock number subjects - N 1,567,231 2,749,445
age - Mean (SD) 31.44 (2.12) 92.58 (4.66)
Medications Amoxiciline N% 43,455 (6.80) 73,696 (27.82)
Ibuprofen N% 4,550 (46.81) 34,744 (61.72)
overall; Female
mock number subjects - N 5,118,733 1,644,105
age - Mean (SD) 22.75 (1.04) 92.02 (4.93)
Medications Amoxiciline N% 56,295 (78.39) 39,168 (82.96)
Ibuprofen N% 30,289 (79.74) 87,080 (21.79)
<40; overall
mock number subjects - N 7,105,515 8,670,615
age - Mean (SD) 6.35 (6.81) 15.20 (7.08)
Medications Amoxiciline N% 22,634 (79.38) 63,896 (76.58)
Ibuprofen N% 17,220 (34.67) 36,884 (31.01)
>=40; overall
mock number subjects - N 3,634,426 6,532,899
age - Mean (SD) 7.86 (4.54) 65.42 (2.94)
Medications Amoxiciline N% 3,969 (8.16) 68,632 (35.05)
Ibuprofen N% 39,478 (67.60) 29,888 (72.41)