1

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’
william3031
  • 1,653
  • 1
  • 18
  • 39
  • When I set the output as an .nb file, I also get the `Error: pandoc document conversion failed with error 67`. – william3031 May 14 '19 at 22:43
  • This runs correctly for me, even when setting self_contained: yes. I wonder if this might be a pandoc issue, what version of R Markdown and pandoc are you using? – joshpk May 15 '19 at 16:14
  • I have run it off another computer (rmarkdown 1.12, pandoc doesn't seem to be installed) and it seems to run fine, like you have said. I will try again on the previous computer (that I had problems with and will need to use) and post the details of that later. – william3031 May 15 '19 at 20:54
  • I have added some details for the computer that I am running it off in the main text. Same though (rmarkdown 1.12; no pandoc) . – william3031 May 15 '19 at 22:14
  • 1
    Maybe just try updating Rstudio to the latest version? Also you can check the pandoc version with rmarkdown::pandoc_version() – joshpk May 16 '19 at 15:56
  • Thanks. The pandoc version is actually `rmarkdown::pandoc_version() ‘1.19.2.1’`. That is also the version on my other computer where it does work. I will look at the RStudio update. – william3031 May 16 '19 at 22:11
  • 1
    Ah, that's strange. I'm not sure I can be of much moreto help other than to say that is a fairly old version of pandoc (I think R Studio ships with 2.6 now), so upgrade everything to the latest version and hopefully that will solve it. Also possibly this thread for a different but maybe related issue might help: https://github.com/rstudio/rstudio/issues/3661 – joshpk May 16 '19 at 22:30
  • Thanks for your help anyway. I have to get IT to update R Studio, so it might take a while. Otherwise, I am running an older version of R Studio with the same version of pandoc on my laptop (the other computer) and it seems to work fine on that. – william3031 May 16 '19 at 22:36

0 Answers0