如何从 rmarkdown::render 函数调用 rmdformat 主题?

How to call rmdformat theme from rmarkdown::render function?

我正在尝试使用脚本中的 rmdformat readthedown 主题呈现 html 文档。但是,它在 .Rmd 文件中没有被识别,现在我正在尝试将它添加到 render() 函数中。

以下工作正常,但在 rmd 文件中指定时未生成 readthedown 主题。

rmarkdown::render('myReport.Rmd',output_format = "html_document")

我尝试了以下操作,但出现错误:

rmarkdown::render('myReport.Rmd',output_format = html_document(theme = readthedown(self_contained =  T, thumbnails=F,lightbox = T,gallery = T,highlight= "tango",toc_depth= 4,css="style.css")))

关于如何从 render()(即从脚本)调用 readthedown 的任何想法?

您可以在 Rmarkdown 文档中指定 readthedown 主题的选项(无论如何您都将对其进行编辑),然后使用 render() 函数渲染它,就像在 readthedown 主题的文档中一样。

这是 rmarkdown 文件:

---
title: "myReport"
output:
  rmdformats::readthedown:
    self_contained: true
    thumbnails: true
    lightbox: true
    gallery: true
    highlight: tango
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

```{r ,results="asis" }
library(xtable)
xtable(summary(iris))

```


```{r}
head(iris)
```

根据文档,您只需调用 rmarkdown 文件的 render() 即可。 html_document 不再需要了。

调用:rmarkdown::render('myReport.Rmd') 将呈现带有 readthedown 主题的文件。