简体   繁体   English

在Rmarkdown笔记本中渲染SQL,而不仅仅是编织时

[英]render SQL in Rmarkdown notebook, not just when knit

If I have an R block in an Rmarkdown notebook, the code is visible in the rendered nb.html file. 如果我在Rmarkdown笔记本中有一个R块,代码在渲染的nb.html文件中可见。 However, if I have a SQL block, I can't find a way to make the code visible in the rendered file. 但是,如果我有一个SQL块,我找不到在渲染文件中使代码可见的方法。

However, if I generate an html_document (standard knitr) instead of an html_notebook , the rendered HTML does include the SQL code (and output). 但是,如果我生成html_document (标准knitr)而不是html_notebook ,则呈现的HTML 确实包含SQL代码(和输出)。

Is there a way to get the notebook output to do something closer to what the knit output does? 有没有办法让笔记本输出更接近编织输出?

I've also encountered this recently, Harlan, and began by asking if there's a way to get notebook output more like knit output. 我最近也遇到过这个,Harlan,并开始询问是否有办法让笔记本输出更像针织输出。

I then wondered if there was a way to get knit output more like notebook output and realised that there was. 然后我想知道是否有办法让针织输出更像笔记本输出,并意识到有。

After asking the folks at RStudio, I learnt that you can add the following line to the YAML options in order to generate a html_document that, when rendered, enables the RMD to be downloaded. 在询问了RStudio的人之后,我了解到你可以将以下行添加到YAML选项中,以便生成一个html_document,在渲染时,可以下载RMD。 Specifically, use: 具体来说,使用:

output:
  html_document:
    code_download: true

I now use that in all of my code and it works well. 我现在在我的所有代码中使用它,它运行良好。 I hope it helps you, too. 我希望它也能帮到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 RMarkdown:UTF-8使用Knit按钮但不适用于render() - RMarkdown: UTF-8 works with Knit button but not with render() 在Rmarkdown中从Knit转换为pdf时出错 - Error when converting from Knit to pdf in Rmarkdown 在 RStudio 中,`knit` 始终有效,但 `rmarkdown::render` 在第二次运行时失败(但不是第一次!) - In RStudio, `knit` always works, but `rmarkdown::render` fails on second run (but not first!) Knit2html不会生成MD文件,但会将我引向rmarkdown :: render - Knit2html is not generating MD file, but referring me to rmarkdown::render Knit & rmarkdown::render() 产生不同的结果(kable 格式;PDF) - Knit & rmarkdown::render() producing different results (kable format; PDF) 从sql块分配数据帧后,R笔记本将不会编织 - R notebook won't knit when data frame has been assigned from with sql chunk RMarkdown渲染到包含子块的笔记本 - RMarkdown render to Notebook with child chunks included 循环中的 Rmarkdown,“knit html”按钮与 rmarkdown::render 不同 output - Rmarkdown in loop, "knit html" button different output than rmarkdown::render 存在简单表格时,无法将rmarkdown转换为PDF - Cannot knit rmarkdown to PDF when a simple table is present Rmarkdown - 代码在脚本上运行正常,但是当 knit 出现错误时 - Rmarkdown - code run ok at script, but when knit gives error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM