Skip to content

add notes on parameterized reports #14

@stefaniebutland

Description

@stefaniebutland

Purpose
Understand how we used parameterized reporting to create Openscapes Champions Certificates, so I can improve and expand their use. Build more R skills.

Outcomes

Process
Find a tutorial or two to start with the basics.

Notes

From Render parameterized reports with Quarto, John Paul Helveston, 2023

One of the most common use cases for me is creating parameterized reports. A parameterized report is one that uses a .qmd file with parameters that can be passed to it while rendering, enabling the ability to create different versions of the output report based on the parameters. ... Using parameters like student_name, grade, and feedback, I am able to use a single .qmd file and then render a unique report for each student where those parameters are replaced with the appropriate information for each student.

This is exactly the starter tutorial I needed because the example parallels my use case! He provides this example code to create a report for every student in his class. Uses a for-loop as we do.

df <- readr::[read_csv](https://readr.tidyverse.org/reference/read_delim.html)("grades.csv")

for (i in 1:[nrow](https://rdrr.io/r/base/nrow.html)(df)) {
    student <- df[i, ] # Each row is a unique student
    quarto::[quarto_render](https://rdrr.io/pkg/quarto/man/quarto_render.html)(
        input = "template.qmd",
        output_file = [paste0](https://rdrr.io/r/base/paste.html)("feedback-", student$name, ".pdf"),
        execute_params = [list](https://rdrr.io/r/base/list.html)(
            name = student$name,
            grade = student$grade
        )
    )
}

Watched 30-min video for this. Super helpful
Repo: https://github.com/jhelvy/quarto-pdf-demo

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions