Convert an already summarised data frame into a publication table
Source:R/as_stats_table.R
as_stats_table.RdWrap 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.
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)
Values were calculated before table formatting.