Combines multiple descriptive tables into a single table with customized row group headers and styling.
This function accepts a list of tables and corresponding group headers, applies consistent styling,
and outputs a styled gt table.
intermediate_header(
tbls,
group_header,
color = "#8ECAE6",
size = 16,
align = "center",
weight = "bold"
)A list of descriptive tables (generated by RastaRocket::desc_var or similar functions).
A character vector specifying the headers for each group of tables.
Must be the same length as tbls.
A character string specifying the background color for the row group headers.
Default is "#8ECAE6".
An integer specifying the font size for the row group headers. Default is 16.
A character string specifying text alignment for the row group headers.
Options are "left", "center", or "right". Default is "center".
A character string specifying the font weight for the row group headers.
Options include "normal", "bold", etc. Default is "bold".
A styled gt table combining the input tables with row group headers.
# Load necessary libraries
library(RastaRocket)
library(dplyr)
# Generate sample data
data <- data.frame(
Age = c(rnorm(45, mean = 50, sd = 10), rep(NA, 5)),
sexe = sample(c("Femme", "Homme"), 50, replace = TRUE, prob = c(0.6, 0.4)),
quatre_modalites = sample(c("A", "B", "C", "D"), 50, replace = TRUE)
)
# Create descriptive tables
tb1 <- data %>%
dplyr::select(Age, sexe) %>%
RastaRocket::desc_var(table_title = "Demographics", group = FALSE)
tb2 <- data %>%
dplyr::select(quatre_modalites) %>%
RastaRocket::desc_var(table_title = "Modalities", group = FALSE)
# Combine and style tables
intermediate_header(
tbls = list(tb1, tb2),
group_header = c("Demographics", "Modalities")
)
Demographics
Characteristic
N
Overall
Demographics
Modalities