| Title: | Graphs and Tables for OMOP Results |
|---|---|
| Description: | Provides methods to transform omop_result objects into formatted tables and figures, facilitating the visualisation of study results working with the Observational Medical Outcomes Partnership (OMOP) Common Data Model. |
| Authors: | Martí Català [aut] (ORCID: <https://orcid.org/0000-0003-3308-9905>), Núria Mercadé-Besora [aut, cre] (ORCID: <https://orcid.org/0009-0006-7948-3747>), Yuchen Guo [ctb] (ORCID: <https://orcid.org/0000-0002-0847-4855>), Elin Rowlands [ctb] (ORCID: <https://orcid.org/0009-0007-6629-4661>), Marta Alcalde-Herraiz [ctb] (ORCID: <https://orcid.org/0009-0002-4405-1814>), Edward Burn [ctb] (ORCID: <https://orcid.org/0000-0002-9286-1128>) |
| Maintainer: | Núria Mercadé-Besora <[email protected]> |
| License: | Apache License (>= 2) |
| Version: | 1.5.0 |
| Built: | 2026-05-22 10:21:33 UTC |
| Source: | https://github.com/darwin-eu/visomopresults |
<summarised_result> object.Create an alluvial plot visualisation from a data frame or a
<summarised_result> object.
alluvialPlot(result, x, y, colour = x, facet = NULL, style = NULL, type = NULL)alluvialPlot(result, x, y, colour = x, facet = NULL, style = NULL, type = NULL)
result |
A |
x |
A character vector of column names to use as alluvial axes, in order from left to right. Must contain at least 2 elements. |
y |
Column or estimate name that is used as y variable. |
colour |
Columns to use to determine the colours. |
facet |
Variables to facet by, a formula can be provided to specify which variables should be used as rows and which ones as columns. |
style |
Visual theme to apply. Character, or |
type |
Character string indicating the output plot format.
See |
A plot object.
result <- dplyr::tibble( treatment_1 = c("A", "A", "A", "B", "B", "B", "C", "C"), treatment_2 = c("A", "A", "B", "A", "B", "B", "B", "C"), treatment_3 = c("A", "B", "B", "A", "A", "B", "B", "C"), count = c(22, 3, 5, 7, 3, 17, 4, 12) ) # basic alluvial plot with 3 axes alluvialPlot( result = result, x = c("treatment_1", "treatment_2", "treatment_3"), y = "count" ) # colour by first axis alluvialPlot( result = result, x = c("treatment_1", "treatment_2", "treatment_3"), y = "count", colour = "treatment_1" ) # colour by multiple variables alluvialPlot( result = result, x = c("treatment_1", "treatment_2", "treatment_3"), y = "count", colour = c("treatment_1", "treatment_2") )result <- dplyr::tibble( treatment_1 = c("A", "A", "A", "B", "B", "B", "C", "C"), treatment_2 = c("A", "A", "B", "A", "B", "B", "B", "C"), treatment_3 = c("A", "B", "B", "A", "A", "B", "B", "C"), count = c(22, 3, 5, 7, 3, 17, 4, 12) ) # basic alluvial plot with 3 axes alluvialPlot( result = result, x = c("treatment_1", "treatment_2", "treatment_3"), y = "count" ) # colour by first axis alluvialPlot( result = result, x = c("treatment_1", "treatment_2", "treatment_3"), y = "count", colour = "treatment_1" ) # colour by multiple variables alluvialPlot( result = result, x = c("treatment_1", "treatment_2", "treatment_3"), y = "count", colour = c("treatment_1", "treatment_2") )
<summarised_result> object.Create a bar plot visualisation from a data frame or a
<summarised_result> object.
barPlot( result, x, y, width = NULL, just = 0.5, position = "dodge", facet = NULL, colour = NULL, style = NULL, type = NULL, label = character() )barPlot( result, x, y, width = NULL, just = 0.5, position = "dodge", facet = NULL, colour = NULL, style = NULL, type = NULL, label = character() )
result |
A |
x |
Column or estimate name that is used as x variable. |
y |
Column or estimate name that is used as y variable. |
width |
Bar width, as in |
just |
Adjustment for column placement, as in |
position |
Position of bars, can be either |
facet |
Variables to facet by, a formula can be provided to specify which variables should be used as rows and which ones as columns. |
colour |
Columns to use to determine the colours. |
style |
Visual theme to apply. Character, or |
type |
Character string indicating the output plot format.
See |
label |
Character vector with the columns to display interactively in
|
A plot object.
result <- mockSummarisedResult() |> dplyr::filter(variable_name == "age") barPlot( result = result, x = "cohort_name", y = "mean", facet = c("age_group", "sex"), colour = "sex")result <- mockSummarisedResult() |> dplyr::filter(variable_name == "age") barPlot( result = result, x = "cohort_name", y = "mean", facet = c("age_group", "sex"), colour = "sex")
<summarised_result> object.Create a box plot visualisation from a data frame or a
<summarised_result> object.
boxPlot( result, x, lower = "q25", middle = "median", upper = "q75", ymin = "min", ymax = "max", facet = NULL, colour = NULL, style = NULL, type = NULL, label = character() )boxPlot( result, x, lower = "q25", middle = "median", upper = "q75", ymin = "min", ymax = "max", facet = NULL, colour = NULL, style = NULL, type = NULL, label = character() )
result |
A |
x |
Column or estimate name that is used as x variable. |
lower |
Estimate name for the lower quantile of the box. |
middle |
Estimate name for the middle line of the box. |
upper |
Estimate name for the upper quantile of the box. |
ymin |
Lower limit of error bars, if provided is plot using
|
ymax |
Upper limit of error bars, if provided is plot using
|
facet |
Variables to facet by, a formula can be provided to specify which variables should be used as rows and which ones as columns. |
colour |
Columns to use to determine the colours. |
style |
Visual theme to apply. Character, or |
type |
Character string indicating the output plot format.
See |
label |
Character vector with the columns to display interactively in
|
A ggplot2 object.
dplyr::tibble(year = "2000", q25 = 25, median = 50, q75 = 75, min = 0, max = 100) |> boxPlot(x = "year")dplyr::tibble(year = "2000", q25 = 25, median = 50, q75 = 75, min = 0, max = 100) |> boxPlot(x = "year")
This function styles character vectors or column names in a data frame. The styling function can be customised, or you can provide specific replacements for certain values.
customiseText( x, fun = function(x) stringr::str_to_sentence(gsub("_", " ", x)), custom = NULL, keep = NULL )customiseText( x, fun = function(x) stringr::str_to_sentence(gsub("_", " ", x)), custom = NULL, keep = NULL )
x |
A character vector to style text. |
fun |
A styling function to apply to text in |
custom |
A named character vector indicating custom names for specific
values in |
keep |
Either a character vector of names to keep unchanged. If NULL, all names will be styled. |
A character vector of styled text or a data frame with styled column names.
# Styling a character vector customiseText(c("some_column_name", "another_column")) # Custom styling for specific values customiseText(x = c("some_column", "another_column"), custom = c("Custom Name" = "another_column")) # Keeping specific values unchanged customiseText(x = c("some_column", "another_column"), keep = "another_column") # Styling column names and variables in a data frame dplyr::tibble( some_column = c("hi_there", "rename_me", "example", "to_keep"), another_column = 1:4, to_keep = "as_is" ) |> dplyr::mutate( "some_column" = customiseText(some_column, custom = c("EXAMPLE" = "example"), keep = "to_keep") ) |> dplyr::rename_with(.fn = ~ customiseText(.x, keep = "to_keep"))# Styling a character vector customiseText(c("some_column_name", "another_column")) # Custom styling for specific values customiseText(x = c("some_column", "another_column"), custom = c("Custom Name" = "another_column")) # Keeping specific values unchanged customiseText(x = c("some_column", "another_column"), keep = "another_column") # Styling column names and variables in a data frame dplyr::tibble( some_column = c("hi_there", "rename_me", "example", "to_keep"), another_column = 1:4, to_keep = "as_is" ) |> dplyr::mutate( "some_column" = customiseText(some_column, custom = c("EXAMPLE" = "example"), keep = "to_keep") ) |> dplyr::rename_with(.fn = ~ customiseText(.x, keep = "to_keep"))
List of mock results
datadata
A list of mock results for quarto and shiny vignette examples
Returns an empty plot
emptyPlot(title = "No data to plot", subtitle = "", type = NULL, style = NULL)emptyPlot(title = "No data to plot", subtitle = "", type = NULL, style = NULL)
title |
Title to use in the empty plot. |
subtitle |
Subtitle to use in the empty plot. |
type |
Character string indicating the output plot format.
See |
style |
Visual theme to apply. Character, or |
An empty ggplot object
emptyPlot()emptyPlot()
Returns an empty table
emptyTable(type = NULL, style = NULL)emptyTable(type = NULL, style = NULL)
type |
Character string specifying the desired output table format.
See |
style |
Defines the visual formatting of the table. This argument can be provided in one of the following ways:
|
An empty table of the class specified in type
emptyTable(type = "flextable")emptyTable(type = "flextable")
Formats estimate_name and estimate_value columns by changing the name of the estimate name and/or joining different estimates together in a single row.
formatEstimateName( result, estimateName = NULL, keepNotFormatted = TRUE, useFormatOrder = TRUE )formatEstimateName( result, estimateName = NULL, keepNotFormatted = TRUE, useFormatOrder = TRUE )
result |
A |
estimateName |
Named list of estimate name's to join, sorted by computation order. Indicate estimate_name's between <...>. |
keepNotFormatted |
Whether to keep rows not formatted. |
useFormatOrder |
Whether to use the order in which estimate names appear in the estimateName (TRUE), or use the order in the input dataframe (FALSE). |
A <summarised_result> object.
result <- mockSummarisedResult() result |> formatEstimateName( estimateName = c( "N (%)" = "<count> (<percentage>%)", "N" = "<count>" ), keepNotFormatted = FALSE )result <- mockSummarisedResult() result |> formatEstimateName( estimateName = c( "N (%)" = "<count> (<percentage>%)", "N" = "<count>" ), keepNotFormatted = FALSE )
Formats the estimate_value column of <summarised_result> object by editing
number of decimals, decimal and thousand/millions separator marks.
formatEstimateValue( result, decimals = c(integer = 0, numeric = 2, percentage = 1, proportion = 3), decimalMark = ".", bigMark = "," )formatEstimateValue( result, decimals = c(integer = 0, numeric = 2, percentage = 1, proportion = 3), decimalMark = ".", bigMark = "," )
result |
A |
decimals |
Number of decimals per estimate type (integer, numeric, percentage, proportion), estimate name, or all estimate values (introduce the number of decimals). |
decimalMark |
Decimal separator mark. |
bigMark |
Thousand and millions separator mark. |
A <summarised_result>.
result <- mockSummarisedResult() result |> formatEstimateValue(decimals = 1) result |> formatEstimateValue(decimals = c(integer = 0, numeric = 1)) result |> formatEstimateValue(decimals = c(numeric = 1, count = 0))result <- mockSummarisedResult() result |> formatEstimateValue(decimals = 1) result |> formatEstimateValue(decimals = c(integer = 0, numeric = 1)) result |> formatEstimateValue(decimals = c(numeric = 1, count = 0))
Pivots a <summarised_result> object based on the column names in header,
generating specific column names for subsequent header formatting in
formatTable function.
formatHeader( result, header, delim = "\n", includeHeaderName = TRUE, includeHeaderKey = TRUE )formatHeader( result, header, delim = "\n", includeHeaderName = TRUE, includeHeaderKey = TRUE )
result |
A |
header |
Names of the variables to make headers. |
delim |
Delimiter to use to separate headers. |
includeHeaderName |
Whether to include the column name as header. |
includeHeaderKey |
Whether to include the header key (header, header_name, header_level) before each header type in the column names. |
A tibble with rows pivotted into columns with key names for subsequent header formatting.
result <- mockSummarisedResult() result |> formatHeader( header = c( "Study cohorts", "group_level", "Study strata", "strata_name", "strata_level" ), includeHeaderName = FALSE )result <- mockSummarisedResult() result |> formatHeader( header = c( "Study cohorts", "group_level", "Study strata", "strata_name", "strata_level" ), includeHeaderName = FALSE )
To indicate which was the minimum cell counts where estimates have been suppressed.
formatMinCellCount(result)formatMinCellCount(result)
result |
A |
result <- mockSummarisedResult() result |> formatMinCellCount()result <- mockSummarisedResult() result |> formatMinCellCount()
Creates a flextable object from a dataframe using a delimiter to span the header, and allows to easily customise table style.
formatTable( x, type = NULL, delim = "\n", style = NULL, na = "–", title = NULL, subtitle = NULL, caption = NULL, groupColumn = NULL, groupAsColumn = FALSE, groupOrder = NULL, merge = "all_columns" )formatTable( x, type = NULL, delim = "\n", style = NULL, na = "–", title = NULL, subtitle = NULL, caption = NULL, groupColumn = NULL, groupAsColumn = FALSE, groupOrder = NULL, merge = "all_columns" )
x |
A dataframe. |
type |
Character string specifying the desired output table format.
See |
delim |
Delimiter to separate headers. |
style |
Defines the visual formatting of the table. This argument can be provided in one of the following ways:
|
na |
How to display missing values. Not used for "datatable" and "reactable". |
title |
Title of the table, or NULL for no title. Not used for "datatable". |
subtitle |
Subtitle of the table, or NULL for no subtitle. Not used for "datatable" and "reactable". |
caption |
Caption for the table, or NULL for no caption. Text in
markdown formatting style (e.g. |
groupColumn |
Columns to use as group labels, to see options use
*tidy: The tidy format applied to column names replaces "_" with a space and
converts to sentence case. Use |
groupAsColumn |
Whether to display the group labels as a column (TRUE) or rows (FALSE). Not used for "datatable" and "reactable" |
groupOrder |
Order in which to display group labels. Not used for "datatable" and "reactable". |
merge |
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. Not used for "datatable" and "reactable". |
A formatted table of the class selected in "type" argument.
# Example 1 mockSummarisedResult() |> formatEstimateValue(decimals = c(integer = 0, numeric = 1)) |> formatHeader( header = c("Study strata", "strata_name", "strata_level"), includeHeaderName = FALSE ) |> formatTable( type = "flextable", style = "default", na = "--", title = "fxTable example", subtitle = NULL, caption = NULL, groupColumn = "group_level", groupAsColumn = TRUE, groupOrder = c("cohort1", "cohort2"), merge = "all_columns" ) # Example 2 mockSummarisedResult() |> formatEstimateValue(decimals = c(integer = 0, numeric = 1)) |> formatHeader(header = c("Study strata", "strata_name", "strata_level"), includeHeaderName = FALSE) |> formatTable( type = "gt", 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"), merge = "all_columns" )# Example 1 mockSummarisedResult() |> formatEstimateValue(decimals = c(integer = 0, numeric = 1)) |> formatHeader( header = c("Study strata", "strata_name", "strata_level"), includeHeaderName = FALSE ) |> formatTable( type = "flextable", style = "default", na = "--", title = "fxTable example", subtitle = NULL, caption = NULL, groupColumn = "group_level", groupAsColumn = TRUE, groupOrder = c("cohort1", "cohort2"), merge = "all_columns" ) # Example 2 mockSummarisedResult() |> formatEstimateValue(decimals = c(integer = 0, numeric = 1)) |> formatHeader(header = c("Study strata", "strata_name", "strata_level"), includeHeaderName = FALSE) |> formatTable( type = "gt", 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"), merge = "all_columns" )
<summarised_result> object filled with mock dataCreates an object of the class <summarised_result> with mock data
for illustration purposes.
mockSummarisedResult()mockSummarisedResult()
An object of the class <summarised_result> with mock data.
mockSummarisedResult()mockSummarisedResult()
Names of the columns that can be used in the input arguments for the plot functions.
plotColumns(result)plotColumns(result)
result |
A |
A character vector of supported columns for plots.
result <- mockSummarisedResult() plotColumns(result)result <- mockSummarisedResult() plotColumns(result)
This function provides a list of pre-defined styles for plots that can then
be used in the style argument of the plot functions.
plotStyle()plotStyle()
A character vector indicating the style names.
plotStyle()plotStyle()
This function returns the supported plot types that can be used in the
type argument of the plot functions.
plotType()plotType()
A character vector of supported plot types.
tableType()tableType()
<summarised_result> object.Create a scatter plot visualisation from a data frame or a
<summarised_result> object.
scatterPlot( result, x, y, line, point, ribbon, ymin = NULL, ymax = NULL, facet = NULL, colour = NULL, style = NULL, type = NULL, group = colour, label = character() )scatterPlot( result, x, y, line, point, ribbon, ymin = NULL, ymax = NULL, facet = NULL, colour = NULL, style = NULL, type = NULL, group = colour, label = character() )
result |
A |
x |
Column or estimate name that is used as x variable. |
y |
Column or estimate name that is used as y variable. |
line |
Whether to plot a line using |
point |
Whether to plot points using |
ribbon |
Whether to plot a ribbon using |
ymin |
Lower limit of error bars, if provided is plot using
|
ymax |
Upper limit of error bars, if provided is plot using
|
facet |
Variables to facet by, a formula can be provided to specify which variables should be used as rows and which ones as columns. |
colour |
Columns to use to determine the colours. |
style |
Visual theme to apply. Character, or |
type |
Character string indicating the output plot format.
See |
group |
Columns to use to determine the group. |
label |
Character vector with the columns to display interactively in
|
A plot object.
result <- mockSummarisedResult() |> dplyr::filter(variable_name == "age") scatterPlot( result = result, x = "cohort_name", y = "mean", line = TRUE, point = TRUE, ribbon = FALSE, facet = age_group ~ sex)result <- mockSummarisedResult() |> dplyr::filter(variable_name == "age") scatterPlot( result = result, x = "cohort_name", y = "mean", line = TRUE, point = TRUE, ribbon = FALSE, facet = age_group ~ sex)
Set format options for all subsequent plots unless state a different style in a specific function
setGlobalPlotOptions(style = NULL, type = NULL)setGlobalPlotOptions(style = NULL, type = NULL)
style |
Visual theme to apply. Character, or |
type |
Character string indicating the output plot format.
See |
Set format options for all subsequent tables unless state a different style in a specific function
setGlobalTableOptions(style = NULL, type = NULL)setGlobalTableOptions(style = NULL, type = NULL)
style |
Defines the visual formatting of the table. This argument can be provided in one of the following ways:
|
type |
Character string specifying the desired output table format.
See |
setGlobalTableOptions(style = "darwin", type = "tinytable") result <- mockSummarisedResult() result |> visOmopTable( estimateName = c("N%" = "<count> (<percentage>)", "N" = "<count>", "Mean (SD)" = "<mean> (<sd>)"), header = c("cohort_name"), rename = c("Database name" = "cdm_name"), groupColumn = strataColumns(result) ) # drop global options: setGlobalTableOptions(style = NULL, type = NULL)setGlobalTableOptions(style = "darwin", type = "tinytable") result <- mockSummarisedResult() result |> visOmopTable( estimateName = c("N%" = "<count> (<percentage>)", "N" = "<count>", "Mean (SD)" = "<mean> (<sd>)"), header = c("cohort_name"), rename = c("Database name" = "cdm_name"), groupColumn = strataColumns(result) ) # drop global options: setGlobalTableOptions(style = NULL, type = NULL)
Names of the columns that can be used in the input arguments for the table functions.
tableColumns(result)tableColumns(result)
result |
A |
A character vector of supported columns for tables.
result <- mockSummarisedResult() tableColumns(result)result <- mockSummarisedResult() tableColumns(result)
visOmopTable() and visTable()
This function provides a list of allowed inputs for the .option argument in
visOmopTable() and visTable(), and their corresponding default values.
tableOptions()tableOptions()
A named list of default options for table customisation.
tableOptions()tableOptions()
This function provides a list of pre-defined styles for tables that can then
be used in the style argument of the table functions.
tableStyle()tableStyle()
A character vector indicating the style names.
tableStyle()tableStyle()
This function returns the supported table classes that can be used in the
type argument of visOmopTable(), visTable(), and formatTable()
functions.
tableType()tableType()
A character vector of supported table types.
tableType()tableType()
Apply a pre-defined visOmopResults theme to a ggplot
themeVisOmop(style = NULL, fontsizeRef = NULL)themeVisOmop(style = NULL, fontsizeRef = NULL)
style |
Visual theme to apply. Character, or |
fontsizeRef |
An integer to use as reference when adjusting label fontsize. |
result <- mockSummarisedResult() |> dplyr::filter(variable_name == "age") barPlot( result = result, x = "cohort_name", y = "mean", facet = c("age_group", "sex"), colour = "sex" ) + themeVisOmop()result <- mockSummarisedResult() |> dplyr::filter(variable_name == "age") barPlot( result = result, x = "cohort_name", y = "mean", facet = c("age_group", "sex"), colour = "sex" ) + themeVisOmop()
<summarised_result>
This function combines the functionalities of formatEstimateValue(),
estimateName(), formatHeader(), and formatTable()
into a single function specifically for <summarised_result> objects.
visOmopTable( result, estimateName = character(), header = character(), settingsColumn = character(), groupColumn = character(), rename = character(), type = NULL, hide = character(), columnOrder = character(), factor = list(), style = NULL, showMinCellCount = TRUE, .options = list() )visOmopTable( result, estimateName = character(), header = character(), settingsColumn = character(), groupColumn = character(), rename = character(), type = NULL, hide = character(), columnOrder = character(), factor = list(), style = NULL, showMinCellCount = TRUE, .options = list() )
result |
A |
estimateName |
A named list of estimate names to join, sorted by
computation order. Use |
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:
|
settingsColumn |
A character vector with the names of settings to
include in the table. To see options use |
groupColumn |
Columns to use as group labels, to see options use
*tidy: The tidy format applied to column names replaces "_" with a space and
converts to sentence case. Use |
rename |
A named vector to customise column names, e.g., c("Database name" = "cdm_name"). The function renames all column names not specified here into a tidy* format. |
type |
Character string specifying the desired output table format.
See |
hide |
Columns to drop from the output table. By default, |
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 |
style |
Defines the visual formatting of the table. This argument can be provided in one of the following ways:
|
showMinCellCount |
If |
.options |
A named list with additional formatting options.
|
A formatted table of the class selected in "type" argument.
result <- mockSummarisedResult() result |> visOmopTable( estimateName = c("N%" = "<count> (<percentage>)", "N" = "<count>", "Mean (SD)" = "<mean> (<sd>)"), header = c("cohort_name"), rename = c("Database name" = "cdm_name"), groupColumn = strataColumns(result) ) result |> visOmopTable( estimateName = c( "N%" = "<count> (<percentage>)", "N" = "<count>", "Mean (SD)" = "<mean> (<sd>)" ), header = c("cohort_name"), rename = c("Database name" = "cdm_name"), groupColumn = strataColumns(result), type = "reactable" )result <- mockSummarisedResult() result |> visOmopTable( estimateName = c("N%" = "<count> (<percentage>)", "N" = "<count>", "Mean (SD)" = "<mean> (<sd>)"), header = c("cohort_name"), rename = c("Database name" = "cdm_name"), groupColumn = strataColumns(result) ) result |> visOmopTable( estimateName = c( "N%" = "<count> (<percentage>)", "N" = "<count>", "Mean (SD)" = "<mean> (<sd>)" ), header = c("cohort_name"), rename = c("Database name" = "cdm_name"), groupColumn = strataColumns(result), type = "reactable" )
<data.table>
This function combines the functionalities of formatEstimateValue(),
formatEstimateName(), formatHeader(), and formatTable()
into a single function. While it does not require the input table to be
a <summarised_result>, it does expect specific fields to apply some
formatting functionalities.
visTable( result, estimateName = character(), header = character(), groupColumn = character(), rename = character(), type = NULL, hide = character(), style = NULL, .options = list() )visTable( result, estimateName = character(), header = character(), groupColumn = character(), rename = character(), type = NULL, hide = character(), style = NULL, .options = list() )
result |
A table to format. |
estimateName |
A named list of estimate names to join, sorted by
computation order. Use |
header |
A vector specifying the elements to include in the header.
The order of elements matters, with the first being the topmost header.
The vector elements can be column names or labels for overall headers.
The table must contain an |
groupColumn |
Columns to use as group labels, to see options use
*tidy: The tidy format applied to column names replaces "_" with a space and
converts to sentence case. Use |
rename |
A named vector to customise column names, e.g., c("Database name" = "cdm_name"). The function renames all column names not specified here into a tidy* format. |
type |
Character string specifying the desired output table format.
See |
hide |
Columns to drop from the output table. |
style |
Defines the visual formatting of the table. This argument can be provided in one of the following ways:
|
.options |
A named list with additional formatting options.
|
A formatted table of the class selected in "type" argument.
result <- mockSummarisedResult() result |> visTable( estimateName = c("N%" = "<count> (<percentage>)", "N" = "<count>", "Mean (SD)" = "<mean> (<sd>)"), header = c("Estimate"), rename = c("Database name" = "cdm_name"), groupColumn = c("strata_name", "strata_level"), hide = c("additional_name", "additional_level", "estimate_type", "result_type") )result <- mockSummarisedResult() result |> visTable( estimateName = c("N%" = "<count> (<percentage>)", "N" = "<count>", "Mean (SD)" = "<mean> (<sd>)"), header = c("Estimate"), rename = c("Database name" = "cdm_name"), groupColumn = c("strata_name", "strata_level"), hide = c("additional_name", "additional_level", "estimate_type", "result_type") )