Hey everyone,
I’ve been thinking about how I use automated reports. There are a few ways:
- For documenting how I’ve cleaned data so I can send to collaborators who aren’t used to coding to confirm decisions I’ve made
- To make outputs for presentations or reports.
- For making training materials.
.
I’m sure there are many more!
How do you use Quarto or Markdown? If you can share any screenshots or examples of what you’ve done then that would be great.
I’d also like to know about any little tips or tricks that you use for your automated reports.
Hi Chris,
I don’t use automated reports for my daily work, but this year we received a training on Quarto and I’m using it a lot to generate/update teaching materials and conference presentations. Here are some screenshots:
Teaching material for the MSc in Public Health:
Teaching materials for the course of Advanced Epidemiology:
Presentation for the IV Latin-american Congress of Animal Leptospirosis:
1 Like
Hi Chris,
As a PhD student, I don’t have to create automated reports in my work, but I do use Quarto for many other purposes:
-
Quarto manuscript: This output format is a very nice way to work in a polyglot project, where your team members don’t need to “speak” the same language. Basically it allows you to create a main page - which is the manuscript, and sourcing tables, figures from other notebooks which can be written by Quarto, Jupyter Notebook. Attached screenshot is an example of my project:
-
Quarto website: A quick solution to have your personal website
-
Survey down: surveydown-dev/surveydown: Markdown-Based Surveys Using R, Quarto, and Shiny. I haven’t tried this one myself, but found it to be very interesting
2 Likes
TL;DR: Something fun that I’ve done recently is render a .Rmd within a for_loop to create a PowerPoint deck of exploratory data analysis maps and graphs.
I used this tutorial from Casey Jeselma, although there is also a tutorial on StackOverflow here.
More details: My analysis uses data from 66 villages, and each village had pre- and post-intervention data. I found it would be useful to have 2 maps of each village (one pre and one post), along with Difference in K functions, along with a local joincount statistic (eventually). Because I wanted to do the same analysis for all 66 villages, I immediately went with iterating the same analyses and plots for each village.
An issue that I ran into was the PowerPoint output. It just wasn’t what I needed. To solve this issue, I created a new master slidedeck (more info here) so that my output would be easier to read. Keep in mind that this is just exploratory data analysis, so I wasn’t looking for anything pretty, just functional. The end result was a 463-slide PowerPoint presentation (7 slides per 66 villages + Title slide) that took ~1.5 hours for the code to run. It took a little bit to tweak the code to work (multiple graphs on a single PowerPoint slide can be finicky), but it sure beat having to manually copy and paste all the graphs into the PowerPoint.
Vague picture of the result, since some data are identifiable:
1 Like
Hi Chris,
I haven’t ventured into quarto yet, but I use R markdown for the following:
- Automating routine surveillance reports
- Automating situation reports for outbreaks
- Helping colleagues with exploratory analysis using parameterised reports
- Instead of notebook when doing my own exploratory analysis as it is easy to build the analysis by chunks and then I can ‘upgrade’ to a full markdown report if needed
- Creating flex dashboard (my newest venture with R markdown)
Tips and tricks:
- If creating an MS Word output where I need all the organisational branding etc, I modify the word template document and set it up on the way I want it. This can get a bit fiddly if you want very specific styles, fonts etc for each level header, but worth the pain.
- If I want an executive summary / abstract box, I create the style in the MS Word template, then use a bit of CSS in my r markdown to apply that style and encapsulate the relevant summary text in the box.
- If updates since the last report need to be highlighted, I add parameters to upload the current and last dataset, then create a grid of all the figures to compare them and identify the ones that changed. I use ftext() to apply the highlight conditionally. It doesn’t look pretty (I mean reading the code) but after a long exchange with the author of Officer package and friends, he advised this was the best approach to get it into the box I created with CSS currently (would love to know if / when a more legible approach is created though).
- I create functions for anything that has to be a function or that has to be repeated over different parts of the data (including data cleaning). It makes the code easier to maintain and the R markdown easier to follow as it is just focused on the outputs.
- I set the language in parameters with ‘lang’ and also Sys.setlocale() in the setup chunk. This ensures that graphs with date axes etc are displayed in the right language.
- I set flextable defaults in the setup chunk too so that I don’t have to repeat these settings each time I make a table.
- I have recently started using flexdashboard via R markdown rather than shiny for some things - I find the structure much easier to follow.
I would attach a picture but they have sensitive info in them so can’t unfortunately - what I can say is that all these customisations do yield a very nice result in MS Word.
On my wish list is a way to switch back and forth between rendered word document and putting the additions in R markdown so that the edits are included in the next run and it would be easier to collaborate with others that don’t use R. There are a few options I have looked at that go some way towards this, but they aren’t very tidyverse friendly. Another feature on my wish list would be a preview of figures with text box underneath so that the person running the report can check the figures, write their interpretation in the text box and then knit the whole thing. I could sort this with a shiny app for specific reports but wonder if there are other ways to do this.
I’m using Quarto/Markdown as an integral part of a reporting project. The goal is to create a collection of data reports in PDF format, one for each of our network’s 17 health clinics. These reports are generated from raw data extracts stored in CSV files.
My workflow consists of several steps:
-
An R script to import, manage, and analyze the raw data. This script saves my analysis outputs into output files.
-
A Quarto template (recently converted from Rmd) to be knitted into a PDF report. In this template I have code to read data from the files produced in the previous step, ggplot and kable to create plots and data tables, as well as text to describe the data presented.
-
Another R script that contains a for loop. This loop iterates through 17 clinic names and passes each name as a parameter to the Quarto template. The template then knits the report for each clinic, resulting in a separate report for each clinic.
The reports follow a consistent format thanks to Quarto/Rmd. It also helps keep the workflow organized and automated. Happy to discuss in more detail if anyone is interested!