Dad*_*ner 6 markdown r rstudio knitr r-markdown
我试图找出RStudio在按下RStudio版本0.98.1091中的"编织HTML"按钮时使用的命令和默认选项,因为当我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
---
Run Code Online (Sandbox Code Playgroud)
按下"编织HTML"按钮时,我得到以下markdown文件:
# Report Title
Daddy the Runner
`r format(Sys.time(), '%A, %B %d, %Y')`
Run Code Online (Sandbox Code Playgroud)
当我执行以下命令:时knit("myReport.Rmd"),我得到以下markdown文件:
---
title: "Report Title"
author: Daddy the Runner
date: "Saturday, January 10, 2015"
output:
html_document:
keep_md: true
---
Run Code Online (Sandbox Code Playgroud)
显然,RStudio按钮正在使用其他一些选项生成中间降价文件,但我无法在RStudio文档中找到有关它的任何信息.
关键问题是日期线.出于某种原因,RStudio在制作markdown文件时不会在标题中执行内联r块.(但是,它会在生成最终HTML之前执行.)然而,knit()函数调用会在生成markdown文件时执行内联块.
我在两个降价文件中注意到的唯一其他差异与图的生成有关.这两种方法生成不同大小的图形(命令行:504 x 504)与(按钮:672 x 480)并将它们放在不同的目录中.
在Rstudio 0.96的R Markdown文件中按"Knit HTML"时,我尝试了这个命令的运行方式.问题是插入一个Sys.sleep(30)电话,但没有提供任何关于RStudio用来编织文档的信息.它确实暂停了R Markdown控制台窗口中的输出,这是不必要的,因为RStudio始终保留所有输出.我在输出中没有看到的是RStudio发出的命令.
任何洞察这些差异的性质将不胜感激.虽然我喜欢使用IDE环境和它们提供的便利,但我真的很想了解它们正在做什么,这样我就能更好地预测它们的行为.
当我查看 RMarkdown 选项卡(控制台选项卡右侧)时,看起来它们正在运行knitr::knit,然后是一个相当复杂的pandocshell 行
/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版本。
所以对我来说,RStudio 正在执行以下操作:
步骤#2 是对标头的解释
---
title: "Report Title"
author: Daddy the Runner
date: "`r format(Sys.time(), '%A, %B %d, %Y')`"
output:
html_document:
keep_md: true
---
Run Code Online (Sandbox Code Playgroud)
发生。
HTH。