Set the style used for the subtitle of the tablespan table.
Usage
style_subtitle(
tbl,
background_color = NULL,
text_color = NULL,
font_size = NULL,
bold = FALSE,
italic = FALSE,
...
)Details
The styling for openxlsx and gt works differently:
- openxlsx_style must be a style object created with openxlsx::createStyle. This style will then be applied to the subtitle - gt_style must be a list of gt::tab_style objects to be applied to the table
Examples
library(tablespan)
library(dplyr)
data("mtcars")
# We want to report the following table:
summarized_table <- mtcars |>
group_by(cyl, vs) |>
summarise(N = n(),
mean_hp = mean(hp),
sd_hp = sd(hp),
mean_wt = mean(wt),
sd_wt = sd(wt))
#> `summarise()` has regrouped the output.
#> ℹ Summaries were computed grouped by cyl and vs.
#> ℹ Output is grouped by cyl.
#> ℹ Use `summarise(.groups = "drop_last")` to silence this message.
#> ℹ Use `summarise(.by = c(cyl, vs))` for per-operation grouping
#> (`?dplyr::dplyr_by`) instead.
# Create a tablespan:
tbl <- tablespan(data = summarized_table,
formula = Cylinder:cyl + Engine:vs ~
N +
(`Horse Power` = Mean:mean_hp + SD:sd_hp) +
(`Weight` = Mean:mean_wt + SD:sd_wt),
title = "Motor Trend Car Road Tests",
subtitle = "A table created with tablespan",
footnote = "Data from the infamous mtcars data set.")
if(require_gt(throw = FALSE))
tbl |>
style_subtitle(bold = TRUE) |>
as_gt()
Motor Trend Car Road Tests
A table created with tablespan
Data from the infamous mtcars data set.