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

Rendering a parametrised Quarto report for multiple input parameters overwrites output figures #205

Open
milanmlft opened this issue Aug 20, 2024 · 0 comments

Comments

@milanmlft
Copy link

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.

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

No branches or pull requests

1 participant