visOmopTable: Format a <summarised_result> object into a gt, flextable, or...

View source: R/visOmopTable.R

visOmopTableR Documentation

Format a ⁠<summarised_result>⁠ object into a gt, flextable, or tibble object

Description

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)
  )

visOmopResults documentation built on Sept. 24, 2024, 1:08 a.m.