I am creating a website with
Rscript -e "rmarkdown::render_site()"
I am generating both html and pdf versions of documents. A plot generated in a chunk does not appear unless the pdf doc is generated before the html doc.
Here are the files:
index.Rmd
---
title: "My Website"
---
* [Test1 page](test1.html)
* [Test2 page](test2.html)
_site.yml
name: "my-website"
test1.Rmd (html generated first)
---
output:
html_document: default
pdf_document: default
---
```{r, message=FALSE, echo=FALSE}
library(ggplot2)
ggplot(mtcars, aes(x=mpg, y=disp)) + geom_point()
```
test2.Rmd (pdf generated first)
---
output:
pdf_document: default
html_document: default
---
```{r, message=FALSE, echo=FALSE}
library(ggplot2)
ggplot(mtcars, aes(x=mpg, y=disp)) + geom_point()
```
After running render_site() via Rscript, test1.html is blank --- there is no test1_files subdirectory. However, test2.html shows this plot (and of course test2_files exists):
This happens with both Rmarkdown 1.10 and 1.10.14, the development version as of October 31.
In a more complicated real life example, the plots don't appear even if I switch the document order, but I am hoping that the answer to this problem will help with the more complicated one.
UPDATE: In addition to the suggestions by @giocomai, a workaround is to compile test1.Rmd twice:
Rscript -e "rmarkdown::render_site()"
Rscript -e "rmarkdown::render_site('test1.Rmd')"
This seems to work even if you compile multiple single files. Presumably the clean-up is less aggressive in the single-file case.
