Streamlined reportifyr workflow
streamlined_reportifyr_workflow.Rmd
library(reportifyr)
#> ── Needed reportifyr options ───────────────────────────────────────────────────
#> ✖ options('venv_dir') is not set. venv will be created in Project root
#> ℹ Please set all options for package to work.
#> ── Optional version options ────────────────────────────────────────────────────
#> ▇ options('uv.version') is not set. Default is 0.5.1
#> ▇ options('python.version') is not set. Default is system version
#> ▇ options('python-docx.version') is not set. Default is 1.1.2
#> ▇ options('pyyaml.version') is not set. Default is 6.0.2
options("venv_dir" = file.path(here::here(), "vignettes"))
initialize_report_project(file.path(here::here(), "vignettes"))
#> Creating python virtual environment with the following settings:
#> venv_dir: /home/runner/work/reportifyr/reportifyr/vignettes
#> python-docx.version: 1.1.2
#> pyyaml.version: 6.0.2
#> uv.version: 0.5.1
#> python.version: 3.10.12
#> Copied standard_footnotes.yaml into /home/runner/work/reportifyr/reportifyr/vignettes/report
reportifyr
also offers some wrapper functions to
streamline and ease report generation and report updating. Instead of
adding bookmarks, tables, plots, and footnotes in a step-wise process,
you can call build_report
to perform all of those actions.
Additionally, if your document already contains figures and tables
inserted via reportifyr
, this wrapper function will remove
those objects before updating to prevent duplication.
# Specify input and output .docx files
docx_shell <- file.path(here::here(), "vignettes", "report", "shell", "template.docx")
docx_out <- file.path(here::here(), "vignettes", "report", "draft", "draft.docx")
# Specify paths to tables and figures directories and the standard_footnotes.yaml
tables_path <- file.path(here::here(), "vignettes", "OUTPUTS", "tables")
figures_path <- file.path(here::here(), "vignettes", "OUTPUTS", "figures")
footnotes <- file.path(here::here(), "vignettes", "report", "standard_footnotes.yaml")
build_report(docx_in = docx_shell,
docx_out = docx_out,
figures_path = figures_path,
tables_path = tables_path,
standard_footnotes_yaml = footnotes)
#> 1.593 sec elapsed
#> 0.207 sec elapsed
#> 0.501 sec elapsed
This produces the same reportifyr
draft as does the
step-wise process, but with only a single function call.
And we can remove the magic strings and bookmarks with the same
finalize_document
function:
docx_final <- file.path(here::here(), "vignettes", "report", "final", "report.docx")
finalize_document(docx_in = docx_out, docx_out = docx_final)
The magic strings and bookmarks are removed and all links between the
document and reportifyr
are severed.