Build an assembly spec (one editable row per RTF) (deprecated)
Source:R/assemble_spec.R
assemble_spec.RdDeprecated in 0.8.x (warns once a session, still works); removed in
0.9.0. It is assemble_folder() without an output_file.
Arguments
- dir
Directory to scan (ignored if
filesis given).- files
Optional explicit vector of
.rtfpaths (overridesdir).- recursive
Passed to
assemble_files()when scanningdir.
Value
A data.frame with columns:
orderinteger, the assembly order (editable).
filepath to the
.rtf.tabletable number read from the header (or
NA).headingsection heading to print above this entry in the TOC (
NA= none); fill these in to group entries.labelthe TOC entry text (defaults to
"Table N <title>").levelTOC indent level of the entry (default
2).pagespage count of the file (informational).
Details
Reads the table number and title from each RTF's running header (the format
written by rtfreporter's headers) and returns a data.frame – the
assembly spec – with one row per file. Edit it (rename labels, add
section headings, change level, reorder rows, or drop rows) and pass it
to assemble_from_spec().
Examples
# two TFL files in a folder, as a study's output
dir <- file.path(tempdir(), "tfl")
dir.create(dir, showWarnings = FALSE)
for (t in c("14.1.1", "14.2.1")) {
doc <- rtf_document() |>
rtf_tables(data.frame(Parameter = "Age", Value = "75.1")) |>
rtf_titles(list(c(paste("Table", t), "Safety Population")))
generate_rtfreport(doc, file.path(dir, paste0("t", gsub(".", "_", t,
fixed = TRUE), ".rtf")), overwrite = TRUE)
}
# instead: the folder's table of contents, edited, then assembled
spec <- assemble_folder(dir)
spec$heading[spec$table == "14.1.1"] <- "Demographics" # group entries
assemble_rtf(toc = spec, output_file = tempfile(fileext = ".rtf"))