Combine Multiple TFL Specifications and/or Reports into a Single Report
Source:R/create_report.R
create_report.RdThis function takes multiple TFL specification objects and/or previously created TFL report objects and combines them into a single report object matching the spec_schema_v2 structure. Each spec is keyed by a combination of its variable name and metadata hash (for direct specs) or preserves original keys (for specs from reports).
Arguments
- ...
One or more objects of class
TFL_specorTFL_report, or plainlists whose elements areTFL_spec/TFL_reportobjects.TFL_specobjects produced bycreate_table(),create_text()orcreate_figure().TFL_reportobjects produced by previous calls tocreate_report().listarguments are expanded in place; for eachTFL_specelement the list slot name (if any) is used as the key basis. Unnamed slots fall back to<outer_arg_name>_<i>(orspec_<i>when the outer argument is itself a literallist(...)call). Nested lists are not supported.Arguments are processed in order; each new
TFL_specis keyed by the argument name combined with the spec metadata hash.TFL_reportobjects are flattened and their spec keys are preserved.
Value
A named list where each element is a TFL_spec object,
keyed by the pattern <variable_name>_<hash> for direct specs, or
original keys for specs extracted from input reports.
Result has class TFL_report.
Details
The function performs the following operations:
Flattens all inputs (expands
listarguments and extracts specs fromTFL_reportobjects).Auto-disambiguates duplicate keys among newly-added specs by appending a numeric suffix (
_2,_3, ...) to the name basis; duplicate keys originating fromTFL_reportarguments still trigger a hard error.Consolidates styles within newly-added
TFL_specobjects only (specs fromTFL_reportare already consolidated).Assigns a global
docOrderinteger (1, 2, 3, ...) based on final position.Preserves existing
dataRefvalues and warns if duplicates detected.Returns a named list keyed by
<variable_name>_<hash>or original report keys.
Examples
if (FALSE) { # \dontrun{
spec1 <- create_table(mtcars)
spec2 <- create_text()
final_report <- create_report(spec1, spec2)
# Combining with a previous report
spec3 <- create_figure("path/to/image.png")
combined <- create_report(final_report, spec3)
# Passing a named list of specs
out <- list(t1 = spec1, t2 = spec2)
report_from_list <- create_report(out)
} # }