Skip to contents

The render_report function is called once for each report to be created. render_report_safely wraps render_report in purrr::safely.

Usage

render_report(
  p_df = filter_report(df = RUBer::df_example, report_nr = 6L),
  p_df_stg = NULL,
  report_nr = 6L,
  rmd_template = fs::path_package(package = "RUBer", "rmarkdown", "templates",
    "datenreport-2022", "skeleton", "skeleton.Rmd"),
  output_directory = fs::path_temp(),
  output_filename = fs::path_file(fs::file_temp(pattern = "RUBer_report_", ext =
    ".docx")),
  title = "Title",
  author = "Author",
  date = format(Sys.Date(), format = "%B %Y"),
  font_file = "RubFlama-Regular.ttf",
  path_figure_template = fs::file_temp(pattern = "figure_template_", ext = ".Rmd"),
  post_process = TRUE,
  quiet = FALSE
)

render_report_safely(...)

Arguments

p_df

Data frame containing the data for all reports

p_df_stg

Optional data frame with information on cases

report_nr

Report number of the report

rmd_template

Path to the R Markdown File for that report, defaults to Datenreport 2022 template from RUBer package

output_directory

Output directory for the rendered report, defaults to here::here("output")

output_filename

Output filename for the rendered report, defaults to p_df[[1, "file_name"]]

title

Character, title for the title page

author

Character, author for the title page

date

Date of the report displayed on the title page, defaults to format(Sys.Date(), format= "%B %Y").

font_file

Character, font file to use in all plots, defaults to "RubFlama-Regular.ttf"

path_figure_template

Character, file path to write the dynamically generated figure chunks to file (useful for debugging purposes). Defaults to fs::file_temp(pattern = "figure_template_", ext = ".Rmd")

post_process

Boolean, whether post_process gets called on the output file

quiet

An option to suppress printing during rendering from knitr, pandoc command line and others. Passed on to rmarkdown::render

...

Arguments passed on to render_report

Value

Invisibly returns p_df

Examples

# Check if pandoc is available in the minimum required version
pandoc_available <- rmarkdown::pandoc_available(
  version = "2.0",
  error = FALSE
)

if(pandoc_available){

  # Get paths for skeleton.Rmd
  skeleton_location <- fs::path_package(
    package = "RUBer",
    "rmarkdown",
    "templates",
    "datenreport-2022",
    "skeleton",
    "skeleton.Rmd"
  )

  # Session based output directory
  output_directory <- fs::path_temp()

  # File name for the report output file
  output_filename <- fs::path_file(
    fs::file_temp(
      pattern = "RUBer_report_",
      ext = ".docx"
    )
  )

  # Full path to output file
  path_report_docx <- fs::path(
    output_directory,
    output_filename
  )

  # Create output directory
  fs::dir_create(
    output_directory
  )

  # Copy all files in the skeleton folder to the output directory
  fs::file_copy(
    path = fs::dir_ls(
      fs::path_dir(
        skeleton_location
      )
    ),
    new_path = output_directory
  )

  # Render the report in the temporary output directory
  render_report(
    rmd_template = skeleton_location,
    output_directory = output_directory,
    output_filename = output_filename
  )
}
#> 
#> 
#> processing file: skeleton.Rmd
#> 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |.                                                                     |   2%
#>    inline R code fragments
#> 
#> 
  |                                                                            
  |..                                                                    |   4%
#> label: setup (with options) 
#> List of 1
#>  $ include: logi FALSE
#> 
#> 
  |                                                                            
  |....                                                                  |   5%
#>   ordinary text without R code
#> 
#> 
  |                                                                            
  |.....                                                                 |   7%
#> label: data
#> 
  |                                                                            
  |......                                                                |   9%
#>   ordinary text without R code
#> 
#> 
  |                                                                            
  |.......                                                               |  11%
#> label: figure_template (with options) 
#> List of 1
#>  $ eval: logi TRUE
#> 
#> 
  |                                                                            
  |.........                                                             |  12%
#>   ordinary text without R code
#> 
#> 
  |                                                                            
  |..........                                                            |  14%
#> label: unnamed-chunk-1
#> 
  |                                                                            
  |...........                                                           |  16%
#>   ordinary text without R code
#> 
#> 
  |                                                                            
  |............                                                          |  18%
#> label: unnamed-chunk-2
#> 
  |                                                                            
  |..............                                                        |  19%
#>   ordinary text without R code
#> 
#> 
  |                                                                            
  |...............                                                       |  21%
#> label: pagebreak-metrics-before
#> 
  |                                                                            
  |................                                                      |  23%
#>   ordinary text without R code
#> 
#> 
  |                                                                            
  |.................                                                     |  25%
#> label: metrics (with options) 
#> List of 3
#>  $ tab.cap : chr "PLACEHOLDER_TABDie Datenreporte der Lehrberichtserstattung 2021/2022 im Gesamtüberblick[^icons]"
#>  $ tab.id  : chr "metrics-tab"
#>  $ ft.align: chr "left"
#> 
#> 
  |                                                                            
  |..................                                                    |  26%
#>   ordinary text without R code
#> 
#> 
  |                                                                            
  |....................                                                  |  28%
#> label: stg-cases-eb (with options) 
#> List of 3
#>  $ tab.cap : chr "PLACEHOLDER_TABVerteilung der Studienfälle auf das 1. und 2. Studienfach je Studiengang bei der Studieneingangsbefragung"
#>  $ tab.id  : chr "stg-cases-tag-eb"
#>  $ ft.align: chr "left"
#> 
#> 
  |                                                                            
  |.....................                                                 |  30%
#>   ordinary text without R code
#> 
#> 
  |                                                                            
  |......................                                                |  32%
#> label: stg-cases-vb (with options) 
#> List of 3
#>  $ tab.cap : chr "PLACEHOLDER_TABVerteilung der Studienfälle auf das 1. und 2. Studienfach je Studiengang bei der Studienverlaufsbefragung"
#>  $ tab.id  : chr "stg-cases-tag-vb"
#>  $ ft.align: chr "left"
#> 
#> 
  |                                                                            
  |.......................                                               |  33%
#>   ordinary text without R code
#> 
#> 
  |                                                                            
  |.........................                                             |  35%
#> label: stg-cases-ab (with options) 
#> List of 3
#>  $ tab.cap : chr "PLACEHOLDER_TABVerteilung der Studienfälle auf das 1. und 2. Studienfach je Studiengang bei der Absolvent:innenbefragung"
#>  $ tab.id  : chr "stg-cases-tag-ab"
#>  $ ft.align: chr "left"
#> 
#> 
  |                                                                            
  |..........................                                            |  37%
#>   ordinary text without R code
#> 
#> 
  |                                                                            
  |...........................                                           |  39%
#> label: funded-projects-table (with options) 
#> List of 3
#>  $ tab.cap : chr "PLACEHOLDER_TABFörderungen für Weiterentwicklung der Lehre"
#>  $ tab.id  : chr "projects-tab"
#>  $ ft.align: chr "left"
#> 
#> 
  |                                                                            
  |............................                                          |  40%
#>   ordinary text without R code
#> 
#> 
  |                                                                            
  |.............................                                         |  42%
#> label: showtext-on (with options) 
#> List of 1
#>  $ include: logi FALSE
#> 
#> 
  |                                                                            
  |...............................                                       |  44%
#>   ordinary text without R code
#> 
#> 
  |                                                                            
  |................................                                      |  46%
#> label: create-figures (with options) 
#> List of 1
#>  $ include: logi FALSE
#> 
#> 
  |                                                                            
  |.................................                                     |  47%
#>   ordinary text without R code
#> 
#> 
  |                                                                            
  |..................................                                    |  49%
#> label: paste-figures (with options) 
#> List of 1
#>  $ results: chr "asis"
#> 
#> 
  |                                                                            
  |....................................                                  |  51%
#>   ordinary text without R code
#> 
#> 
  |                                                                            
  |.....................................                                 |  53%
#> label: showtext-off (with options) 
#> List of 1
#>  $ include: logi FALSE
#> 
#> 
  |                                                                            
  |......................................                                |  54%
#>   ordinary text without R code
#> 
#> 
  |                                                                            
  |.......................................                               |  56%
#> label: items-child (with options) 
#> List of 1
#>  $ child: chr "items.Rmd"
#> 
#> 
#> 
#> processing file: ./items.Rmd
#> 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |......................................................................| 100%
#>   ordinary text without R code
#> 
#> 
#> 
  |                                                                            
  |.........................................                             |  58%
#>   ordinary text without R code
#> 
#> 
  |                                                                            
  |..........................................                            |  60%
#> label: pagebreak-items-table
#> 
  |                                                                            
  |...........................................                           |  61%
#>   ordinary text without R code
#> 
#> 
  |                                                                            
  |............................................                          |  63%
#> label: items-table (with options) 
#> List of 3
#>  $ tab.cap : chr "PLACEHOLDER_TABAcht Items je Abschlussart mit besonders großen Abweichungen zur Fächergruppe"
#>  $ tab.id  : chr "items-tab"
#>  $ ft.align: chr "left"
#> 
#> 
  |                                                                            
  |.............................................                         |  65%
#>   ordinary text without R code
#> 
#> 
  |                                                                            
  |...............................................                       |  67%
#> label: studieneingang (with options) 
#> List of 3
#>  $ tab.cap : chr "PLACEHOLDER_TABZusammensetzung Studieneingangsbefragung"
#>  $ tab.id  : chr "eb-tab"
#>  $ ft.align: chr "left"
#> 
#> 
  |                                                                            
  |................................................                      |  68%
#>   ordinary text without R code
#> 
#> 
  |                                                                            
  |.................................................                     |  70%
#> label: pagebreak-eb
#> 
  |                                                                            
  |..................................................                    |  72%
#>   ordinary text without R code
#> 
#> 
  |                                                                            
  |....................................................                  |  74%
#> label: studienverlauf (with options) 
#> List of 3
#>  $ tab.cap : chr "PLACEHOLDER_TABZusammensetzung Studienverlaufsbefragung"
#>  $ tab.id  : chr "vb-tab"
#>  $ ft.align: chr "left"
#> 
#> 
  |                                                                            
  |.....................................................                 |  75%
#>   ordinary text without R code
#> 
#> 
  |                                                                            
  |......................................................                |  77%
#> label: pagebreak-vb
#> 
  |                                                                            
  |.......................................................               |  79%
#>   ordinary text without R code
#> 
#> 
  |                                                                            
  |........................................................              |  81%
#> label: studienabschluss (with options) 
#> List of 3
#>  $ tab.cap : chr "PLACEHOLDER_TABZusammensetzung Absolvent:innenbefragung"
#>  $ tab.id  : chr "ab-tab"
#>  $ ft.align: chr "left"
#> 
#> 
  |                                                                            
  |..........................................................            |  82%
#>   ordinary text without R code
#> 
#> 
  |                                                                            
  |...........................................................           |  84%
#> label: pagebreak-ab
#> 
  |                                                                            
  |............................................................          |  86%
#>   ordinary text without R code
#> 
#> 
  |                                                                            
  |.............................................................         |  88%
#> label: studiengaenge (with options) 
#> List of 3
#>  $ tab.cap : chr "PLACEHOLDER_TABBerücksichtigte Studiengänge"
#>  $ tab.id  : chr "stg-tab"
#>  $ ft.align: chr "left"
#> 
#> 
  |                                                                            
  |...............................................................       |  89%
#>   ordinary text without R code
#> 
#> 
  |                                                                            
  |................................................................      |  91%
#> label: pagebreak-studiengaenge
#> 
  |                                                                            
  |.................................................................     |  93%
#>   ordinary text without R code
#> 
#> 
  |                                                                            
  |..................................................................    |  95%
#> label: studiengaenge-ausgeschlossen (with options) 
#> List of 3
#>  $ tab.cap : chr "PLACEHOLDER_TABAusgeschlossene Studiengänge"
#>  $ tab.id  : chr "stg-excluded-tab"
#>  $ ft.align: chr "left"
#> 
#> 
  |                                                                            
  |....................................................................  |  96%
#>   ordinary text without R code
#> 
#> 
  |                                                                            
  |..................................................................... |  98%
#> label: pagebreak-studiengaenge-ausgeschlossen
#> 
  |                                                                            
  |......................................................................| 100%
#>   ordinary text without R code
#> 
#> 
#> output file: skeleton.knit.md
#> /usr/bin/pandoc +RTS -K512m -RTS skeleton.knit.md --to docx --from markdown+autolink_bare_uris+tex_math_single_backslash --output /tmp/Rtmp3VOgTy/RUBer_report_371669c4933b.docx --lua-filter /home/runner/work/_temp/Library/rmarkdown/rmarkdown/lua/pagebreak.lua --table-of-contents --toc-depth 2 --highlight-style tango --reference-doc /home/runner/work/_temp/Library/RUBer/rmarkdown/templates/datenreport-2022/skeleton/rub_reference_2021.docx --filter /usr/bin/pandoc-citeproc 
#> 
#> Output created: /tmp/Rtmp3VOgTy/RUBer_report_371669c4933b.docx
#>  Report "/tmp/Rtmp3VOgTy/RUBer_report_371669c4933b.docx" was written successfully.