No solution offered yet and cross-posted to RStudio community: https://community.rstudio.com/t/rmarkdown-does-not-render-pdfs-as-batch/136316
I have a rmarkdown file that renders well in RStudio with the Knitr button or with rmarkdown() but does not render when rendered as part of a batch with purrr::walk() and being passed a parameter. The batch issue only occurs when fig.show="hold", out.width="50%" is included in a section of the rmarkdown file.
library(purrr)
library(tinytex)
SurveySet <- c(20,19,68,79,30,18,42)
purrr::walk(
.x = SurveySet,
~ rmarkdown::render(
input = "Test.Rmd",
output_file = glue::glue("REPORTS/Report Fails {.x}.pdf"),
params = list(Unit = {.x})
)
)
purrr::walk(
.x = SurveySet,
~ rmarkdown::render(
input = "TestWorks.Rmd",
output_file = glue::glue("REPORTS/Report Works {.x}.pdf"),
params = list(Unit = {.x})
)
)
Test.Rmd as
---
title: "`r params$Unit`"
output: pdf_document
params:
Unit: 68
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
## R Markdown
This Document renders with RStudio Knitr button but not with batch
```{r figures-side, fig.show="hold", out.width="50%"}
par(mar = c(4, 4, .1, .1))
plot(cars)
plot(mpg ~ hp, data = mtcars, pch = 19)
```
TestWorks.Rmd as
---
title: "`r params$Unit`"
output: pdf_document
params:
Unit: 68
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
## R Markdown
Without fig.show="hold", out.width="50%" this document renders individually and as batch
```{r figures}
par(mar = c(4, 4, .1, .1))
plot(cars)
plot(mpg ~ hp, data = mtcars, pch = 19)
```