quarto-dev / quarto-dev/quarto-r
Rendering a parametrised Quarto report for multiple input parameters overwrites output figures
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 161
- Forks
- 29
- Avg merge
- 3h 18m
- Merged PRs (30d)
- 1
Description
Taking the following example Quarto file:
# life_expectancy_report.qmd
---
title: "Life Expectancy Report for `r params$country`"
format: html
params:
country: "Afghanistan"
---
```{r}
library(tidyverse)
library(gapminder)
```
```{r}
#| label: life-expectancy-data
life_expectancy <-
gapminder |>
filter(country == params$country)
```
## Life Expectancy in `r params$country`
```{r}
#| label: life-expectancy-plot
ggplot(life_expectancy, aes(year, lifeExp)) +
geom_line() +
theme_minimal()
```
When we generate this report for different countries with the following script:
library(quarto)
countries <- c("Afghanistan", "Belgium", "India", "United Kingdom")
for (country in countries) {
quarto_render(
input = "life_expectancy_report.qmd",
output_file = paste0("life_expectancy_", country, ".html"),
execute_params = list(country = country)
)
}
We get a different report for each country, but they will all show the exact same plot (namely the one for the last country).
I suspect this is because Quarto will overwrite life_expectancy_report_files/figure-html/life-expectancy-plot-1.png for each input parameter and thus the final HTML files will all show the same plot.
This behaviour is different from rmarkdown::render(), which would correctly show the specific plot in each report.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with life_expectancy_report.qmd and the loop calling quarto_render() for the four countries. Start by inspecting how output_file and the generated life_expectancy_report_files/figure-html assets are handled across renders. Done means each generated HTML report displays the plot for its own country, as rmarkdown::render() does.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100