gtTable {visOmopResults}R Documentation

Creates a gt object from a dataframe

Description

Creates a flextable object from a dataframe using a delimiter to span the header, and allows to easily customise table style.

Usage

gtTable(
  x,
  delim = "\n",
  style = "default",
  na = "-",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  groupColumn = NULL,
  groupNameCol = lifecycle::deprecated(),
  groupAsColumn = FALSE,
  groupNameAsColumn = lifecycle::deprecated(),
  groupOrder = NULL,
  colsToMergeRows = NULL
)

Arguments

x

A dataframe.

delim

Delimiter.

style

Named list that specifies how to style the different parts of the gt table. Accepted entries are: title, subtitle, header, header_name, header_level, column_name, group_label, and body. Alternatively, use "default" to get visOmopResults style, or NULL for gt style

na

How to display missing values.

title

Title of the table, or NULL for no title.

subtitle

Subtitle of the table, or NULL for no subtitle.

caption

Caption for the table, or NULL for no caption. Text in markdown formatting style (e.g. ⁠*Your caption here*⁠ for caption in italics).

groupColumn

Column to use as group labels.

groupNameCol

[Deprecated] This argument was renamed to "groupColumn" for consistency throughout the package functions.

groupAsColumn

Whether to display the group labels as a column (TRUE) or rows (FALSE).

groupNameAsColumn

[Deprecated] This argument was renamed to "groupAsColumn" for consistency with the argument "groupColumn".

groupOrder

Order in which to display group labels.

colsToMergeRows

Names of the columns to merge vertically when consecutive row cells have identical values. Alternatively, use "all_columns" to apply this merging to all columns, or use NULL to indicate no merging.

Value

gt object.

A gt table.

Examples

mockSummarisedResult() |>
  formatEstimateValue(decimals = c(integer = 0, numeric = 1)) |>
  formatHeader(header = c("Study strata", "strata_name", "strata_level"),
              includeHeaderName = FALSE) |>
  gtTable(
    style = list("header" = list(
      gt::cell_fill(color = "#d9d9d9"),
      gt::cell_text(weight = "bold")),
      "header_level" = list(gt::cell_fill(color = "#e1e1e1"),
                            gt::cell_text(weight = "bold")),
      "column_name" = list(gt::cell_text(weight = "bold")),
      "title" = list(gt::cell_text(weight = "bold"),
                     gt::cell_fill(color = "#c8c8c8")),
      "group_label" = gt::cell_fill(color = "#e1e1e1")),
    na = "--",
    title = "gtTable example",
    subtitle = NULL,
    caption = NULL,
    groupColumn = "group_level",
    groupAsColumn = FALSE,
    groupOrder = c("cohort1", "cohort2"),
    colsToMergeRows = "all_columns"
  )


[Package visOmopResults version 0.3.0 Index]