Skip to contents

Deprecated in 0.8.x (warns once a session, still works); removed in 0.9.0. It is assemble_folder() without an output_file.

Usage

assemble_spec(dir = NULL, files = NULL, recursive = FALSE)

Arguments

dir

Directory to scan (ignored if files is given).

files

Optional explicit vector of .rtf paths (overrides dir).

recursive

Passed to assemble_files() when scanning dir.

Value

A data.frame with columns:

order

integer, the assembly order (editable).

file

path to the .rtf.

table

table number read from the header (or NA).

heading

section heading to print above this entry in the TOC (NA = none); fill these in to group entries.

label

the TOC entry text (defaults to "Table N <title>").

level

TOC indent level of the entry (default 2).

pages

page 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"))