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(),
  factor = list(),
  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. Elements in header can be:

  • Any of the columns returned by tableColumns(result) to create a header for these columns.

  • Any other input to create an overall header.

settingsColumn

A character vector with the names of settings to include in the table. To see options use settingsColumns(result).

groupColumn

Columns to use as group labels, to see options use tableColumns(result). 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.

factor

A named list where names refer to columns (see available columns in tableColumns()) and list elements are the level order of that column to arrange the results. The column order in the list will be used for arranging the result.

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 2,009,283 3,012,543
age - Mean (SD) 27.92 (5.88) 33.71 (6.72)
Medications Amoxiciline N% 82,683 (49.14) 20,832 (29.82)
Ibuprofen N% 90,252 (24.88) 54,539 (58.02)
<40; Male
mock number subjects - N 8,141,156 7,204,667
age - Mean (SD) 67.27 (4.92) 14.12 (8.20)
Medications Amoxiciline N% 61,938 (84.54) 22,826 (38.13)
Ibuprofen N% 43,803 (74.80) 72,510 (38.57)
>=40; Male
mock number subjects - N 6,537,801 2,614,054
age - Mean (SD) 6.01 (2.86) 35.26 (9.15)
Medications Amoxiciline N% 84,105 (2.51) 5,044 (24.78)
Ibuprofen N% 80,676 (40.72) 52,548 (23.65)
<40; Female
mock number subjects - N 3,532,520 1,076,963
age - Mean (SD) 98.85 (0.08) 40.14 (6.90)
Medications Amoxiciline N% 42,725 (54.84) 56,182 (34.50)
Ibuprofen N% 48,150 (56.17) 61,894 (51.95)
>=40; Female
mock number subjects - N 5,965,949 2,624,227
age - Mean (SD) 28.23 (5.51) 88.89 (4.92)
Medications Amoxiciline N% 76,929 (95.55) 69,425 (41.98)
Ibuprofen N% 25,804 (75.05) 17,896 (64.12)
overall; Male
mock number subjects - N 7,277,044 1,867,062
age - Mean (SD) 55.41 (8.13) 31.26 (6.47)
Medications Amoxiciline N% 71,214 (14.05) 22,794 (65.91)
Ibuprofen N% 17,014 (55.12) 76,772 (82.99)
overall; Female
mock number subjects - N 9,955,685 5,424,417
age - Mean (SD) 89.01 (6.44) 6.17 (4.57)
Medications Amoxiciline N% 6,337 (71.03) 96,031 (95.40)
Ibuprofen N% 16,061 (47.33) 81,629 (91.91)
<40; overall
mock number subjects - N 4,980,553 655,185
age - Mean (SD) 2.28 (0.69) 67.95 (1.25)
Medications Amoxiciline N% 42,601 (12.64) 49,284 (46.99)
Ibuprofen N% 66,139 (6.26) 19,458 (92.94)
>=40; overall
mock number subjects - N 2,302,948 8,803,851
age - Mean (SD) 67.77 (7.29) 37.82 (6.04)
Medications Amoxiciline N% 8,828 (83.57) 72,321 (15.06)
Ibuprofen N% 46,855 (9.39) 21,251 (64.53)