Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add notes on parameterized reports #14

Open
stefaniebutland opened this issue Feb 21, 2024 · 1 comment
Open

add notes on parameterized reports #14

stefaniebutland opened this issue Feb 21, 2024 · 1 comment
Assignees

Comments

@stefaniebutland
Copy link
Member

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

@stefaniebutland stefaniebutland self-assigned this Feb 21, 2024
@stefaniebutland
Copy link
Member Author

created a repo for working through this: https://github.com/stefaniebutland/param-reports

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant