I want to render multiple html documents using quarto_render
I have a main.qmd containing:
library(quarto)
library(glue)
# List of IDs of interest
ids <- c("A", "B", "C")
# Generate individual reports
sapply(ids, function(id) {
quarto_render(
input = "test.qmd",
output_format = "html",
output_file = glue("report_{id}.html"),
execute_params = list(ID = id),
debug = TRUE
)
})
within test.qmd I filter the dataframe using the ID value and then plot the filtered data.frame
---
params:
ID: null
---
```{r}
# Load packages
library(tidyverse)
``` {r r params$ID}
L3 <- LETTERS[1:3]
char <- sample(L3, 12, replace = TRUE)
df <- data.frame(x = 1, y = 1:12, char = char)
df_test <- df %>%
filter(char == params$ID)
print(params$ID)
print(df_test)
ggplot(df_test, aes(x = x, y = y)) +
geom_point()
Although print(params$ID), print(df_test) look correct. The plots are all the same and reflect the points of char == C
Does it have to do with the saved .png file that apparently gets overwritten before the documents are created?