Skip to contents

Wrap a data frame or tibble containing values that have already been calculated so it can be rendered, styled, and exported with gtstats. No descriptive statistics, confidence intervals, or p-values are calculated or checked by this function.

Usage

as_stats_table(data, notes = NULL)

Arguments

data

A data frame or tibble containing one row per intended table row.

notes

Optional character vector of explanatory notes to display below the table.

Value

A gt_data_table object. Use customise_table(), to_flextable(), to_gt(), or save_output() to present or export it.

Details

Use summary_table() instead when each row represents a participant or observation and descriptive statistics still need to be calculated. Use epi_table() when events and denominators need to be calculated from a line list or aggregate outbreak/surveillance data.

Examples

summarised <- mtcars |>
  dplyr::summarise(
    Cars = dplyr::n(),
    `Mean mpg` = mean(mpg),
    `Mean weight` = mean(wt)
  )

table <- as_stats_table(
  summarised,
  notes = "Values were calculated before table formatting."
)
customise_table(table, title = "Vehicle summary")

Vehicle summary

Cars

Mean mpg

Mean weight

32

20.09062

3.21725

Values were calculated before table formatting.

to_flextable(table)

Cars

Mean mpg

Mean weight

32

20.09062

3.21725

Values were calculated before table formatting.

to_gt(table)
Cars Mean mpg Mean weight
32 20.09062 3.21725
Values were calculated before table formatting.