我正在试图找出RStudio在按下"编织HTML"时使用的命令和默认选项。 RStudio版本0.98.1091中的按钮,因为当我从控制台运行knit()
函数时,我得到一个略有不同的中间降价文件。
具体来说,当我对R markdown文件使用以下标题时:
---
title: "Report Title"
author: Daddy the Runner
date: "`r format(Sys.time(), '%A, %B %d, %Y')`"
output:
html_document:
keep_md: true
---
按下"编织HTML"我得到以下markdown文件按钮:
# Report Title
Daddy the Runner
`r format(Sys.time(), '%A, %B %d, %Y')`
当我执行以下命令时:knit("myReport.Rmd")
,我得到以下markdown文件:
---
title: "Report Title"
author: Daddy the Runner
date: "Saturday, January 10, 2015"
output:
html_document:
keep_md: true
---
显然,RStudio按钮使用其他一些选项生成中间降价文件,但我无法在RStudio文档中找到有关它的任何信息。
关键问题是日期线。出于某种原因,RStudio在制作markdown文件时不会在标题中执行内联r块。 (但是,它会在生成最终HTML之前执行。)然而,knit()
函数调用会在生成markdown文件时执行内联块。
我在两个降价文件中注意到的唯一其他差异与图的生成有关。这两种方法生成不同大小的图形(命令行:504 x 504)与(按钮:672 x 480)并将它们放在不同的目录中。
我在此What commands are run when pressing "Knit HTML" on an R Markdown file in Rstudio 0.96?问题中尝试了推荐,以插入Sys.sleep(30)
调用,但未提供有关RStudio用于编织文档的调用的任何信息。它确实暂停了R Markdown控制台窗口中的输出,这是不必要的,因为RStudio始终保留所有输出。我在输出中没有看到的是RStudio发出的命令。
对这些差异的本质有任何见解将不胜感激。虽然我喜欢使用IDE环境和它们提供的便利,但我真的很想了解它们正在做什么,所以我可以更好地预测它们的行为。
答案 0 :(得分:4)
正如@rawr在评论中指出的那样:
rmarkdown::render('your_document.Rmd', 'html_document', 'new_titel.html')
工作并创建与Knit HTML
按钮相同的文档。
答案 1 :(得分:0)
当我查看RMarkdown选项卡(控制台选项卡右侧)时,看起来它们运行knitr::knit
,然后是一个相当复杂的pandoc
shell行
/usr/local/lib/rstudio/bin/pandoc/pandoc filename.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output filename.html --smart --email-obfuscation none --self-contained --standalone --section-divs --table-of-contents --toc-depth 3 --template /home/me/R/i686-pc-linux-gnu-library/3.1/rmarkdown/rmd/h/default.html --variable 'theme:flatly' --include-in-header /tmp/user/1001/RtmpKz5GnI/rmarkdown-str3bba3848bd7b.html --mathjax --variable 'mathjax-url:https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --no-highlight --variable highlightjs=/home/cd/R/i686-pc-linux-gnu-library/3.1/rmarkdown/rmd/h/highlight
从最开始/usr/local/lib/rstudio/bin/pandoc/pandoc
我推断他们带来了自己的pandoc
,可能认为重复比调试更好,以便与所有人的特殊pandoc
版本保持良好关系。< / p>
所以对我来说,看起来RStudio正在做以下事情:
和步骤#2是对标题的解释
---
title: "Report Title"
author: Daddy the Runner
date: "`r format(Sys.time(), '%A, %B %d, %Y')`"
output:
html_document:
keep_md: true
---
发生。
HTH。
答案 2 :(得分:0)
我相信它目前使用RMarkdown包中的html_document
函数