Creates the R markdown header, and first setup chunk. The setup chunk quiets messages, attaches any needed packages, and loads the object to be printed.

create_yaml_header(object_path, pkg_to_attach, reference_docx)

Arguments

object_path

(path)
path to saved RDS object file.

pkg_to_attach

(character)
character vector of packages that are attached at the top of the R markdown document. These are needed to access the appropraite print methods for the loaded table object.

reference_docx

(path)
path the reference Word document.

Value

YAML character vector

Examples

create_yaml_header(
  object_path = tempfile(fileext = ".rds"),
  pkg_to_attach = "flextable",
  reference_docx = tempfile(fileext = ".docx")
) |>
  cat(sep = "\n")
#> ---
#> output:
#>   word_document:
#>     reference_docx: /tmp/RtmpxRCBPk/file1e3856f84f81.docx
#> ---
#> 
#> ```{r setup, include=FALSE}
#> knitr::opts_chunk$set(echo = FALSE, message = FALSE)
#> library(flextable)
#> x <- readRDS(file = "/tmp/RtmpxRCBPk/file1e3846bacae8.rds")
#> if (!inherits(x, 'list')) x <- list(x)
#> ```
#>