Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to render a "github_document" Rmd without generating the HTML preview?

I'm maintaining a package and have to rebuild the README.Rmd file every once in a while.

Using the "knit" button in RStudio, the effect is correct: the file README.md is generated at the root of the package, and a README.html preview is created in a temporary file and opened.

However, if I use the following command, the HTML preview is created at the root of the package, which is unnecessary.

rmarkdown::render(input="README.Rmd")

How to tell this preview file to be temporary, or even to not bother to exist at all?

I tried to set intermediates_dir=tempfile() with no effect, and I couldn't find what command RStudio is running on "knit" push. Moreover, it seems that this simple command does not have this side effect when run through Github Actions (link).

PS: Here is a minimal example of my Rmarkdown file (whole file here):

---
  output: github_document
---

Hello Word
like image 440
Dan Chaltiel Avatar asked Oct 25 '25 04:10

Dan Chaltiel


2 Answers

Set the html_preview option to false, like so:

---
output:
  github_document:
    html_preview: false
---

Hello World

This option is documented here. BTW, I suspect that a .html file is generated on the server where the render-rmarkdown action is performed; you don't see it locally because the action only commits changes to .md files:

$ git commit ${RMD_PATH[*]/.Rmd/.md} -m 'Re-build Rmarkdown files' || echo "No changes to commit"
like image 100
Mikael Jagan Avatar answered Oct 26 '25 17:10

Mikael Jagan


This works:

rmarkdown::render("README.Rmd", output_format = "md_document")
like image 43
Ferroao Avatar answered Oct 26 '25 18:10

Ferroao