减少R Markdown HTML输出的文件大小 [英] Reduce file size of R Markdown HTML output
问题描述
如果我创建一个没有图像或代码的非常基本的R Markdown文件并编织此HTML,最终输出的文件大小将超过700kb.有什么办法可以减少HTML文件的大小?
If I create a very basic R Markdown file with no images or code and knit this HTML, I end up with an outputted file size that is more than 700kb in size. Is there any way to reduce the HTML file size?
最小示例:
---
title: "Hello world!"
output:
html_document: default
html_notebook: default
---
Nothing else to say, really.
html_document
的输出文件大小为708.6 kb,而html_notebook
的输出文件为765.7 kb.
The output file from html_document
is 708.6 kb in size, while html_notebook
is 765.7 kb.
推荐答案
如果您想要较小的文件大小,html_vignette
格式是完美的选择.如功能文档中所述:
The html_vignette
format is perfect if you want a smaller file size. As described in the function documentation:
HTML小插图是html_document的轻量级替代,适合包含在要发布到CRAN的软件包中.它可以将基本小插图的大小从100k减少到10k左右.
A HTML vignette is a lightweight alternative to html_document suitable for inclusion in packages to be released to CRAN. It reduces the size of a basic vignette from 100k to around 10k.
以您的示例为例:
---
title: "Hello world!"
output: rmarkdown::html_vignette
---
Nothing else to say, really.
输出为6kB:
您可以在在线文档中了解有关该软件包的更多信息.
You can read more about the package in the online documentation here.
这篇关于减少R Markdown HTML输出的文件大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!