1

We have built a site using rmarkdown::render_site() function. Our site works and renders correctly. However, if there is an error in any of the Markdown files that comprise the site, it will error out. The site is built using something similar to the documentation found below,

https://bookdown.org/yihui/rmarkdown/rmarkdown-site.html

Even if there is an error in one of the files, we would like the file to finish running and output an html file. We have tried adding the following code to the top of each Markdown file per this solution.

knitr::opts_chunk$set(
  echo = TRUE,
  error = TRUE)

However, when these files run using the rmarkdown::render_site() function, the files will stop if there's an error. Does anyone know a fix around this?

1 Answers1

0

render_site() raising an error in that situation is good. Otherwise, you wouldn't be alarmed when something breaks unexpectedly.

If you have a file that contains unfinished work and raises errors you can temporarily,

  • deactivate the offending code chunk(s) by setting the chunk options to eval = FALSE
  • remove {r} after the three tickmarks ```{r} -> ```
  • wrap the offending piece of code in try()

Then reverse the measure, when the issue has been fixed.

Till
  • 3,845
  • 1
  • 11
  • 18
  • 1
    We are using `try()` statements around offending code, but this solution is only effective when we already know which lines of code will throw an error. We're looking for a solution that allows for us to create an output (rendered site) even if there are errors or incomplete files within it; e.g., we have a site made up of 10 files and files 1, 2, and 3 run correctly but file 4 throws an error. Our current script would completely halt at this point, but we want our site to still be rendered even if the output created by file 4 is incomplete/outdated/missing in the rendered site. – Johanna Caskey Jul 10 '23 at 20:14