Title: | Graphs and Tables for OMOP Results |
---|---|
Description: | Provides methods to transform omop_result objects into formatted tables and figures, facilitating the visualization of study results working with the Observational Medical Outcomes Partnership (OMOP) Common Data Model. |
Authors: | Martí Català [aut] , Núria Mercadé-Besora [aut, cre] , Yuchen Guo [aut] |
Maintainer: | Núria Mercadé-Besora <[email protected]> |
License: | Apache License (>= 2) |
Version: | 0.4.00001 |
Built: | 2024-11-09 19:13:21 UTC |
Source: | https://github.com/darwin-eu/visomopresults |
Identifies and returns the unique values in additional_name column.
additionalColumns(result)
additionalColumns(result)
result |
A tibble. |
Unique values of the additional name column.
mockSummarisedResult() |> additionalColumns()
mockSummarisedResult() |> additionalColumns()
<summarised_result>
objectAdd settings columns to a <summarised_result>
object
addSettings( result, settingsColumns = colnames(settings(result)), columns = lifecycle::deprecated() )
addSettings( result, settingsColumns = colnames(settings(result)), columns = lifecycle::deprecated() )
result |
A |
settingsColumns |
Settings to be added as columns, by default all settings will be added. If NULL or empty character vector, no settings will be added. |
columns |
A <summarised_result>
object with the added setting columns.
library(visOmopResults) mockSummarisedResult() |> addSettings(settingsColumns = c("result_type"))
library(visOmopResults) mockSummarisedResult() |> addSettings(settingsColumns = c("result_type"))
<summarised_result>
objectbarPlot(result, x, y, facet = NULL, colour = NULL)
barPlot(result, x, y, facet = NULL, colour = NULL)
result |
A |
x |
Column or estimate name that is used as x variable. |
y |
Column or estimate name that is used as y variable |
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 colors. |
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>
objectboxPlot( result, x = NULL, lower = "q25", middle = "median", upper = "q75", ymin = "min", ymax = "max", facet = NULL, colour = NULL )
boxPlot( result, x = NULL, lower = "q25", middle = "median", upper = "q75", ymin = "min", ymax = "max", facet = NULL, colour = NULL )
result |
A |
x |
Columns to use as x axes. |
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 |
Estimate name for the lower limit of the bars. |
ymax |
Estimate name for the upper limit of the bars. |
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 colors. |
A ggplot2 object.
Filter the additional_name-additional_level pair in a summarised_result
filterAdditional(result, ...)
filterAdditional(result, ...)
result |
A |
... |
Expressions that return a logical value ( |
A <summarised_result>
object with only the rows that fulfill the
required specified additional.
library(dplyr) library(omopgenerics) x <- tibble( "result_id" = 1L, "cdm_name" = "eunomia", "group_name" = "cohort_name", "group_level" = c("cohort1", "cohort2", "cohort3"), "strata_name" = "sex", "strata_level" = "Female", "variable_name" = "number subjects", "variable_level" = NA_character_, "estimate_name" = "count", "estimate_type" = "integer", "estimate_value" = c("100", "44", "14"), "additional_name" = c("year", "time_step", "year &&& time_step"), "additional_level" = c("2010", "4", "2015 &&& 5") ) |> newSummarisedResult() x |> filterAdditional(year == "2010")
library(dplyr) library(omopgenerics) x <- tibble( "result_id" = 1L, "cdm_name" = "eunomia", "group_name" = "cohort_name", "group_level" = c("cohort1", "cohort2", "cohort3"), "strata_name" = "sex", "strata_level" = "Female", "variable_name" = "number subjects", "variable_level" = NA_character_, "estimate_name" = "count", "estimate_type" = "integer", "estimate_value" = c("100", "44", "14"), "additional_name" = c("year", "time_step", "year &&& time_step"), "additional_level" = c("2010", "4", "2015 &&& 5") ) |> newSummarisedResult() x |> filterAdditional(year == "2010")
Filter the group_name-group_level pair in a summarised_result
filterGroup(result, ...)
filterGroup(result, ...)
result |
A |
... |
Expressions that return a logical value ( |
A <summarised_result>
object with only the rows that fulfill the
required specified group.
library(dplyr) library(omopgenerics) x <- tibble( "result_id" = 1L, "cdm_name" = "eunomia", "group_name" = c("cohort_name", "age_group &&& cohort_name", "age_group"), "group_level" = c("my_cohort", ">40 &&& second_cohort", "<40"), "strata_name" = "sex", "strata_level" = "Female", "variable_name" = "number subjects", "variable_level" = NA_character_, "estimate_name" = "count", "estimate_type" = "integer", "estimate_value" = c("100", "44", "14"), "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult() x |> filterGroup(cohort_name == "second_cohort")
library(dplyr) library(omopgenerics) x <- tibble( "result_id" = 1L, "cdm_name" = "eunomia", "group_name" = c("cohort_name", "age_group &&& cohort_name", "age_group"), "group_level" = c("my_cohort", ">40 &&& second_cohort", "<40"), "strata_name" = "sex", "strata_level" = "Female", "variable_name" = "number subjects", "variable_level" = NA_character_, "estimate_name" = "count", "estimate_type" = "integer", "estimate_value" = c("100", "44", "14"), "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult() x |> filterGroup(cohort_name == "second_cohort")
<summarised_result>
using the settingsFilter a <summarised_result>
using the settings
filterSettings(result, ...)
filterSettings(result, ...)
result |
A |
... |
Expressions that return a logical value (columns in settings are used to evaluate the expression), and are defined in terms of the variables in .data. If multiple expressions are included, they are combined with the & operator. Only rows for which all conditions evaluate to TRUE are kept. |
A <summarised_result>
object with only the result_id rows that fulfill
the required specified settings.
library(dplyr) library(omopgenerics) x <- tibble( "result_id" = as.integer(c(1, 2)), "cdm_name" = c("cprd", "eunomia"), "group_name" = "sex", "group_level" = "male", "strata_name" = "sex", "strata_level" = "male", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = "count", "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult(settings = tibble( "result_id" = c(1, 2), "custom" = c("A", "B") )) x x |> filterSettings(custom == "A")
library(dplyr) library(omopgenerics) x <- tibble( "result_id" = as.integer(c(1, 2)), "cdm_name" = c("cprd", "eunomia"), "group_name" = "sex", "group_level" = "male", "strata_name" = "sex", "strata_level" = "male", "variable_name" = "Age group", "variable_level" = "10 to 50", "estimate_name" = "count", "estimate_type" = "numeric", "estimate_value" = "5", "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult(settings = tibble( "result_id" = c(1, 2), "custom" = c("A", "B") )) x x |> filterSettings(custom == "A")
Filter the strata_name-strata_level pair in a summarised_result
filterStrata(result, ...)
filterStrata(result, ...)
result |
A |
... |
Expressions that return a logical value ( |
A <summarised_result>
object with only the rows that fulfill the
required specified strata.
library(dplyr) library(omopgenerics) x <- tibble( "result_id" = 1L, "cdm_name" = "eunomia", "group_name" = "cohort_name", "group_level" = "my_cohort", "strata_name" = c("sex", "sex &&& age_group", "sex &&& year"), "strata_level" = c("Female", "Male &&& <40", "Female &&& 2010"), "variable_name" = "number subjects", "variable_level" = NA_character_, "estimate_name" = "count", "estimate_type" = "integer", "estimate_value" = c("100", "44", "14"), "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult() x |> filterStrata(sex == "Female")
library(dplyr) library(omopgenerics) x <- tibble( "result_id" = 1L, "cdm_name" = "eunomia", "group_name" = "cohort_name", "group_level" = "my_cohort", "strata_name" = c("sex", "sex &&& age_group", "sex &&& year"), "strata_level" = c("Female", "Male &&& <40", "Female &&& 2010"), "variable_name" = "number subjects", "variable_level" = NA_character_, "estimate_name" = "count", "estimate_type" = "integer", "estimate_value" = c("100", "44", "14"), "additional_name" = "overall", "additional_level" = "overall" ) |> newSummarisedResult() x |> filterStrata(sex == "Female")
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, estimateNameFormat = lifecycle::deprecated() )
formatEstimateName( result, estimateName = NULL, keepNotFormatted = TRUE, useFormatOrder = TRUE, estimateNameFormat = lifecycle::deprecated() )
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). |
estimateNameFormat |
deprecated. |
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 )
Creates a flextable object from a dataframe using a delimiter to span the header, and allows to easily customise table style.
formatTable( x, type = "gt", delim = "\n", style = "default", na = "-", title = NULL, subtitle = NULL, caption = NULL, groupColumn = NULL, groupAsColumn = FALSE, groupOrder = NULL, merge = NULL )
formatTable( x, type = "gt", delim = "\n", style = "default", na = "-", title = NULL, subtitle = NULL, caption = NULL, groupColumn = NULL, groupAsColumn = FALSE, groupOrder = NULL, merge = NULL )
x |
A dataframe. |
type |
The desired format of the output table. See |
delim |
Delimiter. |
style |
Named list that specifies how to style the different parts of
the gt or flextable table generated. Accepted style 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/flextable style.
Keep in mind that styling code is different for gt and flextable. To see
the "deafult" style code use |
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. |
groupColumn |
Specifies the columns to use for group labels.
By default, the new group name will be a combination of the column names,
joined by "_". To assign a custom group name, provide a named list such as:
list( |
groupAsColumn |
Whether to display the group labels as a column (TRUE) or rows (FALSE). |
groupOrder |
Order in which to display group labels. |
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. |
A flextable object.
A flextable or gt object.
# 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" )
Creates a flextable object from a dataframe using a delimiter to span the header, and allows to easily customise table style.
fxTable( x, delim = "\n", style = "default", na = "-", title = NULL, subtitle = NULL, caption = NULL, groupColumn = NULL, groupAsColumn = FALSE, groupOrder = NULL, colsToMergeRows = NULL )
fxTable( x, delim = "\n", style = "default", na = "-", title = NULL, subtitle = NULL, caption = NULL, groupColumn = NULL, groupAsColumn = FALSE, groupOrder = NULL, colsToMergeRows = NULL )
x |
A dataframe. |
delim |
Delimiter. |
style |
Named list that specifies how to style the different parts of
the gt or flextable table generated. Accepted style 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/flextable style.
Keep in mind that styling code is different for gt and flextable. To see
the "deafult" gt style code use |
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. |
groupColumn |
Specifies the columns to use for group labels.
By default, the new group name will be a combination of the column names,
joined by "_". To assign a custom group name, provide a named list such as:
list( |
groupAsColumn |
Whether to display the group labels as a column (TRUE) or rows (FALSE). |
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. |
A flextable object.
A flextable object.
Identifies and returns the unique values in group_name column.
groupColumns(result)
groupColumns(result)
result |
A tibble. |
Unique values of the group name column.
mockSummarisedResult() |> groupColumns()
mockSummarisedResult() |> groupColumns()
Creates a flextable object from a dataframe using a delimiter to span the header, and allows to easily customise table style.
gtTable( x, delim = "\n", style = "default", na = "-", title = NULL, subtitle = NULL, caption = NULL, groupColumn = NULL, groupAsColumn = FALSE, groupOrder = NULL, colsToMergeRows = NULL )
gtTable( x, delim = "\n", style = "default", na = "-", title = NULL, subtitle = NULL, caption = NULL, groupColumn = NULL, groupAsColumn = FALSE, groupOrder = NULL, colsToMergeRows = NULL )
x |
A dataframe. |
delim |
Delimiter. |
style |
Named list that specifies how to style the different parts of
the gt or flextable table generated. Accepted style 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/flextable style.
Keep in mind that styling code is different for gt and flextable. To see
the "deafult" style code use |
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. |
groupColumn |
Specifies the columns to use for group labels.
By default, the new group name will be a combination of the column names,
joined by "_". To assign a custom group name, provide a named list such as:
list( |
groupAsColumn |
Whether to display the group labels as a column (TRUE) or rows (FALSE). |
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. |
gt object.
A gt table.
<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()
optionsVisOmopTable()
optionsVisOmopTable()
list of options
Pivot the estimates as new columns in result table.
pivotEstimates(result, pivotEstimatesBy = "estimate_name", nameStyle = NULL)
pivotEstimates(result, pivotEstimatesBy = "estimate_name", nameStyle = NULL)
result |
A |
pivotEstimatesBy |
Names from which pivot wider the estimate values. If NULL the table will not be pivotted. |
nameStyle |
Name style (glue package specifications) to customise names when pivotting estimates. If NULL standard tidyr::pivot_wider formatting will be used. |
A tibble.
result <- mockSummarisedResult() result |> pivotEstimates()
result <- mockSummarisedResult() result |> pivotEstimates()
<summarised_result>
objectscatterPlot( result, x, y, line, point, ribbon, ymin = NULL, ymax = NULL, facet = NULL, colour = NULL, group = colour )
scatterPlot( result, x, y, line, point, ribbon, ymin = NULL, ymax = NULL, facet = NULL, colour = NULL, group = colour )
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 colors. |
group |
Columns to use to determine the group. |
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)
<summarised_result>
Identifies and returns the columns of the settings table
obtained by using settings()
in a <summarised_result>
object.
settingsColumns(result)
settingsColumns(result)
result |
A |
Vector with names of the settings columns
mockSummarisedResult() |> settingsColumns()
mockSummarisedResult() |> settingsColumns()
Pivots the input dataframe so the values of the column additional_name are transformed into columns that contain values from the additional_level column.
splitAdditional(result, keep = FALSE, fill = "overall")
splitAdditional(result, keep = FALSE, fill = "overall")
result |
A dataframe with at least the columns additional_name and additional_level. |
keep |
Whether to keep the original group_name and group_level columns. |
fill |
Optionally, a character that specifies what value should be filled in with when missing. |
A dataframe.
mockSummarisedResult() |> splitAdditional()
mockSummarisedResult() |> splitAdditional()
Pivots the input dataframe so any pair name-level columns are transformed into columns (name) that contain values from the corresponding level.
splitAll(result, keep = FALSE, fill = "overall", exclude = "variable")
splitAll(result, keep = FALSE, fill = "overall", exclude = "variable")
result |
A data.frame. |
keep |
Whether to keep the original name-level columns. |
fill |
A character that specifies what value should be filled in when missing. |
exclude |
Name of a column pair to exclude. |
A dataframe with group, strata and additional as columns.
mockSummarisedResult() |> splitAll()
mockSummarisedResult() |> splitAll()
Pivots the input dataframe so the values of the column group_name are transformed into columns that contain values from the group_level column.
splitGroup(result, keep = FALSE, fill = "overall")
splitGroup(result, keep = FALSE, fill = "overall")
result |
A dataframe with at least the columns group_name and group_level. |
keep |
Whether to keep the original group_name and group_level columns. |
fill |
Optionally, a character that specifies what value should be filled in with when missing. |
A dataframe.
mockSummarisedResult() |> splitGroup()
mockSummarisedResult() |> splitGroup()
Pivots the input dataframe so the values of the name columns are transformed into columns, which values come from the specified level column.
splitNameLevel( result, name = "group_name", level = "group_level", keep = FALSE, fill = "overall" )
splitNameLevel( result, name = "group_name", level = "group_level", keep = FALSE, fill = "overall" )
result |
A |
name |
Column with the names. |
level |
Column with the levels. |
keep |
Whether to keep the original group_name and group_level columns. |
fill |
Optionally, a character that specifies what value should be filled in with when missing. |
A dataframe with the specified name column values as columns.
Pivots the input dataframe so the values of the column strata_name are transformed into columns that contain values from the strata_level column.
splitStrata(result, keep = FALSE, fill = "overall")
splitStrata(result, keep = FALSE, fill = "overall")
result |
A dataframe with at least the columns strata_name and strata_level. |
keep |
Whether to keep the original group_name and group_level columns. |
fill |
Optionally, a character that specifies what value should be filled in with when missing. |
A dataframe.
mockSummarisedResult() |> splitStrata()
mockSummarisedResult() |> splitStrata()
Identifies and returns the unique values in strata_name column.
strataColumns(result)
strataColumns(result)
result |
A tibble. |
Unique values of the strata name column.
mockSummarisedResult() |> strataColumns()
mockSummarisedResult() |> strataColumns()
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 customization.
tableOptions()
tableOptions()
Supported predefined styles for formatted tables
tableStyle(type = "gt", styleName = "default")
tableStyle(type = "gt", styleName = "default")
type |
Character string specifying the formatted table class.
See |
styleName |
A character string specifying the style name. Currently, the package supports only one predefined style: "default". |
A code expression for the selected style and table type.
tableStyle("gt") tableStyle("flextable")
tableStyle("gt") tableStyle("flextable")
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()
<summarised_result>
object into a tidy tibble
Provides tools for obtaining a tidy version of a <summarised_result>
object.
This tidy version will include the settings as columns, estimate_value
will
be pivotted into columns using estimate_name
as names, and group, strata,
and additional will be splitted.
If you want to customise these tidy operations, please use
tidySummarisedResult()
.
## S3 method for class 'summarised_result' tidy(x, ...)
## S3 method for class 'summarised_result' tidy(x, ...)
x |
A |
... |
For compatibility (not used). |
A tibble.
result <- mockSummarisedResult() result |> tidy()
result <- mockSummarisedResult() result |> tidy()
<summarised_result>
Identifies and returns the columns that the tidy version of the
<summarised_result>
will have.
tidyColumns(result)
tidyColumns(result)
result |
A |
Table columns after applying tidy()
function to a
<summarised_result>
.
mockSummarisedResult() |> tidyColumns()
mockSummarisedResult() |> tidyColumns()
Unites targeted table columns into additional_name-additional_level columns.
uniteAdditional( x, cols = character(0), keep = FALSE, ignore = c(NA, "overall") )
uniteAdditional( x, cols = character(0), keep = FALSE, ignore = c(NA, "overall") )
x |
Tibble or dataframe. |
cols |
Columns to aggregate. |
keep |
Whether to keep the original columns. |
ignore |
Level values to ignore. |
A tibble with the new columns.
x <- dplyr::tibble( variable = "number subjects", value = c(10, 15, 40, 78), sex = c("Male", "Female", "Male", "Female"), age_group = c("<40", ">40", ">40", "<40") ) x |> uniteAdditional(c("sex", "age_group"))
x <- dplyr::tibble( variable = "number subjects", value = c(10, 15, 40, 78), sex = c("Male", "Female", "Male", "Female"), age_group = c("<40", ">40", ">40", "<40") ) x |> uniteAdditional(c("sex", "age_group"))
Unites targeted table columns into group_name-group_level columns.
uniteGroup(x, cols = character(0), keep = FALSE, ignore = c(NA, "overall"))
uniteGroup(x, cols = character(0), keep = FALSE, ignore = c(NA, "overall"))
x |
Tibble or dataframe. |
cols |
Columns to aggregate. |
keep |
Whether to keep the original columns. |
ignore |
Level values to ignore. |
A tibble with the new columns.
x <- dplyr::tibble( variable = "number subjects", value = c(10, 15, 40, 78), sex = c("Male", "Female", "Male", "Female"), age_group = c("<40", ">40", ">40", "<40") ) x |> uniteGroup(c("sex", "age_group"))
x <- dplyr::tibble( variable = "number subjects", value = c(10, 15, 40, 78), sex = c("Male", "Female", "Male", "Female"), age_group = c("<40", ">40", ">40", "<40") ) x |> uniteGroup(c("sex", "age_group"))
Unites targeted table columns into a pair of name-level columns.
uniteNameLevel( x, cols = character(0), name = "group_name", level = "group_level", keep = FALSE, ignore = c(NA, "overall") )
uniteNameLevel( x, cols = character(0), name = "group_name", level = "group_level", keep = FALSE, ignore = c(NA, "overall") )
x |
A dataframe. |
cols |
Columns to aggregate. |
name |
Column name of the |
level |
Column name of the |
keep |
Whether to keep the original columns. |
ignore |
Level values to ignore. |
A tibble with the new columns.
Unites targeted table columns into strata_name-strata_level columns.
uniteStrata(x, cols = character(0), keep = FALSE, ignore = c(NA, "overall"))
uniteStrata(x, cols = character(0), keep = FALSE, ignore = c(NA, "overall"))
x |
Tibble or dataframe. |
cols |
Columns to aggregate. |
keep |
Whether to keep the original columns. |
ignore |
Level values to ignore. |
A tibble with the new columns.
x <- dplyr::tibble( variable = "number subjects", value = c(10, 15, 40, 78), sex = c("Male", "Female", "Male", "Female"), age_group = c("<40", ">40", ">40", "<40") ) x |> uniteStrata(c("sex", "age_group"))
x <- dplyr::tibble( variable = "number subjects", value = c(10, 15, 40, 78), sex = c("Male", "Female", "Male", "Female"), age_group = c("<40", ">40", ">40", "<40") ) x |> uniteStrata(c("sex", "age_group"))
<summarised_result>
object into a gt, flextable, or tibble objectThis 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(), 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() )
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() )
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. The input vector elements can be:
|
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 |
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 |
hide |
Columns to drop from the output table. By default, |
showMinCellCount |
If |
.options |
A named list with additional formatting options.
|
split |
|
excludeColumns |
|
formatEstimateName |
|
renameColumns |
A tibble, gt, or flextable object.
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) )
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) )
<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 = "gt", hide = character(), .options = list() )
visTable( result, estimateName = character(), header = character(), groupColumn = character(), rename = character(), type = "gt", hide = character(), .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. 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 them to sentence case. Use |
rename |
A named vector to customize column names, e.g., c("Database name" = "cdm_name"). The function will rename all column names not specified here into a tidy* format. |
type |
The desired format of the output table. See |
hide |
Columns to drop from the output table. |
.options |
A named list with additional formatting options.
|
A tibble, gt, or flextable object.
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") )