Created
February 15, 2024 22:43
-
-
Save edgararuiz/1dca815ab592702de4571b3e023ef3c6 to your computer and use it in GitHub Desktop.
Dynamic code chunks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```{r setup, include = FALSE} | |
suppressPackageStartupMessages(library(tidyverse)) | |
suppressPackageStartupMessages(library(rlang)) | |
``` | |
```{r, echo = FALSE, results='asis'} | |
walk( | |
names(mtcars), | |
~{ | |
curr_var <- .x | |
x <- knitr::knit_child("plot.Rmd", envir = environment(), quiet = TRUE) | |
cat(x, sep = '\n') | |
} | |
) | |
``` | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## `r paste0(curr_var, " vs mpg")` | |
```{r, echo = FALSE} | |
mtcars %>% | |
ggplot() + | |
geom_point(aes(x = mpg, y = !! parse_expr(curr_var))) | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment