Skip to content

Instantly share code, notes, and snippets.

@andrewheiss
Last active April 29, 2024 04:25
Show Gist options
  • Save andrewheiss/222b426ad8e2b177b9a4a0c7e98fe228 to your computer and use it in GitHub Desktop.
Save andrewheiss/222b426ad8e2b177b9a4a0c7e98fe228 to your computer and use it in GitHub Desktop.
---
title: "Testing with lots of plots"
---
```{r}
#| label: fun-generate-chunks
#| include: false
generate_chunk <- function(id) {
paste0(
c(
paste0("```{r fig-", id, ", echo=FALSE}"),
paste0("plot(density(rnorm(1000)), main = '", id, "')"),
"```", "", ""
),
sep = "\n")
}
n_figs <- 15
out <- NULL
for (i in 1:n_figs) {
out <- c(out, generate_chunk(i))
}
```
See @fig-1 through `r paste0("@fig-", n_figs)` and all the other figs here:
`r paste(knitr::knit(text = out), collapse = "\n")`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment