Muk*_*eek 4 r knitr r-markdown
我正在尝试使用Knitr编写简单的纯文本html页面,但是文件大小非常大-1行RMarkdown的文件大小为700KB。我在R 3.4.0和R Studio 1.0.143上
例如,以下RMarkdown文件生成695 kb的文件。当我查看源代码时,这是因为在script标记下有大量的base 64代码。有什么可以做的事情来使文件大小更紧凑,比如我希望它有几个KB
(例如,脚本src =“ data:application / x-javascript; base64,LyohIGpRdW ...并且这种情况永远持续下去)
---
title: "This is a test"
author: "Mukul Pareek"
date: "June 7, 2017"
output: html_document
---
## This is a test file which when knit to html is 695KB
Run Code Online (Sandbox Code Playgroud)
减小HTML文件大小的关键是set theme: null,这意味着摆脱了巨大的Twitter Bootstrap样式。以下是一些示例:
---
title: "This is a test"
author: "Mukul Pareek"
date: "June 7, 2017"
output:
html_document:
theme: null
html_vignette: default
prettydoc::html_pretty: default
---
## This is a test file which when knit to html is 695KB
Run Code Online (Sandbox Code Playgroud)
html_document(theme = NULL)返回一个44kb的文件;html_vignette返回6.1kb; prettydoc::html_pretty返回63.7kb(您需要安装prettydoc软件包)。如果您想使用“华丽的”样式,我认为prettydoc在样式和文件大小之间取得了很好的平衡。否则,您必须忍受那些“香草”风格。
我的临时解决方案是使用BiocStyleBioconductor 的样式。这会将 html 文件大小减少到 50 kb。
---
title: "This is a test"
author: "Mukul Pareek"
date: "June 7, 2017"
output:
BiocStyle::html_document
---
Run Code Online (Sandbox Code Playgroud)
这里找到了一个更极端的解决方案:How to render HTML from RMarkdown without javascript in output
它生成小于 1 kb 的 html 文件。
---
title: "This is a test"
author: "Mukul Pareek"
date: "June 7, 2017"
output:
html_document:
theme: null
highlight: null
mathjax: null
---
Run Code Online (Sandbox Code Playgroud)