Felix Analytix

Felix Analytix

Share this post

Felix Analytix
Felix Analytix
How to FULLY Automate Reports using R
Copy link
Facebook
Email
Notes
More

How to FULLY Automate Reports using R

Using parameters in Quarto to automate the production of customized reports

Felix Analytix's avatar
Felix Analytix
Aug 25, 2024
∙ Paid

Share this post

Felix Analytix
Felix Analytix
How to FULLY Automate Reports using R
Copy link
Facebook
Email
Notes
More
Share

Would you like to know how to automate reports with customized parameters using the R programming language?

In this video you will learn how to:

  • create reports using Quarto in RStudio.

  • add specific parameters / variables to fully customize your reports.

  • use an R script to produce all your reports automatically.

Watch the video now:

Why Automated Reports Are So Useful

Posit, the company who developed and maintains Quarto, just released a new article showing how to use parameters in Quarto to automate Word documents, PowerPoints, PDFs, and HTML pages very easily for full automation.

We’ll go through this article showing you how easy it is now to have specific parameters like years, months, weeks for example for the timeline, or by name, by companies, by regions - whatever you need.

Concrete Example

Here is a concrete example: if you want to create reports for different years, you can choose a year parameters and you can create different Word documents or PDFs based on this unique variable.

As Quarto supports either R or Python, we will concentrate on R programming.

Setting Up Your First Parametric Report

Let’s open RStudio now. In RStudio, you just go to File > New File or click on the new file button and simply click on “Quarto Document”. This will open a window with a title that will be the title of your document, the author (Felix Analytix), and you can choose HTML, PDF, or Word format. Let’s go for Word here.

Here’s our basic Quarto template with parameters:

---
title: "How to Fully Automate Reports using R programming"
author: "Felix Analytix"
format: docx
params:
  name: "Luke Skywalker"
  year: "2024"
---

Hello `{r} params$name`!

## Sub section for `{r} params$year`

Hello !
library(dplyr)

starwars |> 
  dplyr::filter(name == params$name)

Let’s break down what’s happening here:

  1. We add two parameters in our YAML header: name and year

  2. We use the starwars dataset from the dplyr package, which contains information about Star Wars characters

  3. We can reference parameters inline using params$name or params$year

  4. We filter our dataset to show only information for the specified character

When you click “Render”, you’ll get a Word document that says “Hello Luke Skywalker!” and shows the filtered dataset containing only Luke Skywalker’s information.

You can change the parameter values to get different reports for each Star Wars character. For example, changing the name to “C-3PO” will create a report specifically for that character.

Full Automation: Creating Multiple Reports

Now for the most exciting part - full automation! Our goal is to create different reports for each character name with a specific greeting and filtered dataset.

For this, we need to create another R script that will generate all reports automatically:

This post is for paid subscribers

Already a paid subscriber? Sign in
© 2025 Felix Analytix
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share

Copy link
Facebook
Email
Notes
More