Generic function to add header rows. Dispatches to class-specific methods, allowing headers to be added to both spec objects and global options.
Arguments
- spec
Spec object (dispatches on class)
- ...
Up to 3 character strings (left, center, right)
Positional parts represent left, center and right header/footer cells respectively.
Supply fewer than 3 parts if some cells should be empty; use empty string "" for explicit empties.
Each call appends one header/footer row; use the
levelparameter to replace an existing row.
- level
Optional numeric index. If provided, replaces header at that row. If NULL, appends next row.
Details
Each call adds a new header row. Per schema, headers are arrays of arrays (each call = one row).
Examples
# Add to a spec object (one call = one header row)
spec <- create_text() |>
add_header("Study ABC-123", "CONFIDENTIAL", "Page {PAGE}") |>
add_header("Protocol v2.0", "", paste("Date:", format(Sys.Date(), "%Y-%m-%d")))
# Replace an existing row by level instead of appending
spec <- add_header(spec, "Rewritten first row", level = 1)