[英]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.