Primary factory function for creating ClinicalTable objects with proper styling. Supports multiple data types and themes, with optional custom summarization logic.
Arguments
- data
Data to display. Can be:
ADaMDataobject (uses@dataor@filtered_data)LayeredTableobject (built usingbuild_table())AnalysisResultsobject (uses@stats)Raw
data.frame
- type
Character string for table type (e.g., "demographics", "ae_soc")
- title
Table title
- footnotes
Character vector of footnotes
- theme
Theme preset: "hta", "iqwig", "gba", or "clinical" (default: "hta")
- summary_fn
Optional function for custom summarization. Receives the extracted data and should return a data.frame. If NULL, data is used as-is.
- ...
Additional arguments passed to theme functions
Examples
if (FALSE) { # \dontrun{
# Basic usage with data.frame
df <- data.frame(Treatment = c("A", "B"), N = c(100, 95))
table <- create_clinical_table(
data = df,
type = "summary",
title = "Treatment Summary",
footnotes = "ITT Population"
)
# With custom summary function
table <- create_clinical_table(
data = adsl_data,
type = "demographics",
summary_fn = function(d) {
d |> dplyr::summarise(N = dplyr::n(), .by = TRT01P)
},
theme = "iqwig"
)
# With ADaMData object
table <- create_clinical_table(
data = ADaMData(adsl_df, domain = "ADSL"),
type = "demographics",
title = "Baseline Characteristics",
theme = "gba"
)
# With LayeredTable object
demo_lt <- LayeredTable(
data = adsl_df,
trt_var = "TRT01P",
layers = list(
CountLayer(target_var = "SEX", label = "Sex"),
DescriptiveLayer(target_var = "AGE", label = "Age (years)")
)
)
table <- create_clinical_table(
data = demo_lt,
type = "demographics",
title = "Demographics"
)
} # }
