I have a markdown document and want to generate multiple reports from it based on a variable. An example of this is here (sort of an updated version of this):
Script file:
library(knitr)
library(markdown)
library(rmarkdown)
library(glue)
library(tidyverse)
iris_rmd <- iris %>% distinct(Species) %>% pull
for (i in iris_rmd){
selected_iris <- iris_rmd[i]
render(input = "test_iris.Rmd", #the notebook file
output_file = glue("{i}_profile_{Sys.Date()}.html"),
output_dir = 'test_profiles')
}
Notebook file:
---
output:
html_document:
self_contained: no
---
```{r, include = FALSE}
#DON'T KNIT
#RUN THE SCRIPT INSTEAD!!!
```
```{r, include = FALSE}
library(tidyverse)
library(glue)
```
```{r, include = FALSE}
# add variables
selected_iris <- i
data <- iris %>%
filter(Species == selected_iris)
```
```{r}
ggplot(data, aes(Sepal.Length, Sepal.Width)) +
geom_point() + labs(title = glue("{selected_iris}"))
```
I had to change the settings to self_contained: no
in the YAML header as discussed here: pandoc document conversion failed with error 67 but this puts the images in a separate folder.
However, I would like to include the images in the html file (embedding them, like in a normal notebook). I have tried this with the same error too: R-markdown self_contained
Is there a work around for this?
Version details:
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 5.2
year 2018
month 12
day 20
svn rev 75870
language R
version.string R version 3.5.2 (2018-12-20)
nickname Eggshell Igloo
And
Rstudio 1.1.436
rmarkdown 1.12
rmarkdown::pandoc_version() ‘1.19.2.1’