有没有办法在 RStudio 之外使用 DT 生成的数据表来编译 RMarkdown 文档?
我试图在 RMarkdown 文档中包含一个数据表小部件,然后我想使用 knit 和 pandoc 将其转换为 html。这对于 RStudio 来说效果很好,但是如果我尝试对 knit 和 pandoc 做同样的事情,我将无法获得工作的 html 文件。
下面是一个 Rmd 文件的最小示例,它可以与 RStudio 一起使用,但不能与 RStudio 一起使用:
---
title: "Minimal DT example"
---
<style type="text/css"> table, table th, table td { border: none; } </style>
```{r}
library(DT)
datatable(iris)
```
然后我想使用以下方法将其转换为 html:
knitr::knit('example.Rmd')
knitr::pandoc('example.md',format="html")
我知道 RStudio 使用更复杂的 pandoc 调用:
/usr/lib/rstudio/bin/pandoc/pandoc scratch.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output scratch.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template /home/user/R/x86_64-pc-linux-gnu-library/3.1/rmarkdown/rmd/h/default.html --variable 'theme:bootstrap' --include-in-header /tmp/RtmpMLtVfF/rmarkdown-str24935297671d.html --mathjax --variable 'mathjax-url:https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --no-highlight --variable highlightjs=/home/user/R/x86_64-pc-linux-gnu-library/3.1/rmarkdown/rmd/h/highlight
我可以重新创建该 tmp 文件包含在标头中的部分:
/tmp/RtmpMLtVfF/rmarkdown-str24935297671d.html
我假设该文件包含 jquery 和数据表的 js 源。我尝试从包源中手动添加它们 - 但没有成功 - 并且无论如何都希望有一个开箱即用的解决方案。