knitr HTML 输出太大

mom*_*822 5 r knitr r-markdown

我一直在使用rmarkdown/knitrknit to html功能为一些博客生成 html 代码。我发现它非常有用和方便,但最近遇到了一些文件大小问题。

当我编写一个包含使用 shapefile 或ggmap图像的图形的脚本时,html 文件变得太大,博客主机无法理解它(我已经尝试过使用 blogger 和 wordpress)。ggmap我相信这与相对较大的 data.frames/files(shapefiles/被放入 html 形式)有关。我可以做些什么来获得一个可以由博客主机解析的较小的 html 文件吗?

作为参考,rmarkdown 脚本的 html 输出为ggmap1.90MB,其中一个图形使用一层、一层 shapefile 和一些数据,这对于博主或 WordPress 来说太大了,无法在 html 输入中处理。感谢您的任何想法。

Kei*_*itt 2

您可以做的一件事是不使用嵌入图像和其他资源。为此,您可以将self_contained文档的 YAML 标头中的选项设置为false,例如:

---
output:
  html_document:
    self_contained: false
---
Run Code Online (Sandbox Code Playgroud)

更多信息在这里: http: //rmarkdown.rstudio.com/html_document_format.html