Skip to contents

reportifyr

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

reportifyr loads with a message specifying some options that are used to set various values for python setup. You can choose to leave these options unset and default values will be used instead. Or, if you are comfortable setting these values, you can alter where the python virtual environment (.venv) is created and which versions of python, python-docx, and PyYAML are used.

Initializing report project and reportifyr

The first thing to do when using reportifyr is to call the initialize_report_project function. This does several things - it creates all needed directories for saving output figures and tables, sets up the ‘report’ directory, and copies a standard_footnotes.yaml file into the ‘report’ directory that can be used to save footnote definitions. Additionally, it sets up the needed python dependencies in a virtual environment so that the python portion of the reportifyr package can properly function.

You’ll need to provide a directory (typically the project root directory) where reportifyr will look for a few other directories. If the directories are not found, the initialize_report_project function will create them. Specifically, the ‘report’ directory, as well as several sub directories, will be created if not found. The ‘OUTPUTS’ directory, containing ‘tables’, ‘figures’, and ‘listings’ sub directories, will be created if they do not exist. A ‘.venv’ directory will be created, if it doesn’t exist, and python-docx and PyYAML will be saved to this directory.

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

When the virtual environment is initially created (i.e., the first time you call initialize_report_project), reportifyr will notify you of which versions python, python-docx, and PyYAML are being used and where the virtual environment is created. These versions can be set with options before running this function and are displayed when reportifyr is loaded.

Here are all the directories and files that exist after running initialize_report_project:

#> reportifyr/vignettes/.venv
#> reportifyr/vignettes/data/images
#> reportifyr/vignettes/OUTPUTS/figures
#> reportifyr/vignettes/OUTPUTS/listings
#> reportifyr/vignettes/OUTPUTS/tables
#> reportifyr/vignettes/report/draft
#> reportifyr/vignettes/report/final
#> reportifyr/vignettes/report/scripts
#> reportifyr/vignettes/report/shell
#> reportifyr/vignettes/report/standard_footnotes.yaml