Add a user-defined row to a gtstats descriptive table. This is useful for
inserting contextual information such as study period, data source, setting,
or other custom annotations that should appear alongside the main table
content.
Arguments
- x
A
gtstats_summaryobject created withsummary_table().- label
A single character string giving the row label to display in the
Variablecolumn.- overall
Optional value to display in the
Overallcolumn when the descriptive table includesoverall = TRUE.- values
Optional named character vector or named list giving values for displayed group columns. Names must match the displayed group column names, for example
c("am = 1" = "2020-2024", "am = 0" = "2020-2024").- level
Optional text to display in the
Levelcolumn. Defaults to an empty string.
Details
The row is matched to the current table structure automatically:
if
overall = TRUE, anOverallcolumn is supportedif
byis used, values must be named using displayed group column namesif neither
overallnorbyis used, a singleValuecolumn is used
Examples
res <- summary_table(mtcars, by = am, include = c(mpg, wt), overall = TRUE) |>
add_row(
label = "Study period",
overall = "2020-2024",
values = c("am = 1" = "2020-2024", "am = 0" = "2020-2024")
)