create_yaml_header.RdCreates 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)(path)
path to saved RDS object file.
(character)
character vector of packages that are attached at the top of the R markdown
document. These are needed to access the appropriate print methods
for the loaded table object.
(path)
path the reference Word document.
YAML character vector
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/RtmpVH4Fyk/file1a965384b885.docx
#> ---
#>
#> ```{r setup, include=FALSE}
#> knitr::opts_chunk$set(echo = FALSE, message = FALSE)
#> library(flextable)
#> x <- readRDS(file = "/tmp/RtmpVH4Fyk/file1a96211ac26e.rds")
#> if (!is_simple_list(x)) x <- list(x)
#> print_obj <- function(obj) {
#> if (inherits(obj, 'grob')) grid::grid.draw(obj) else obj
#> }
#> ```
#>