Harlan
Harlan

Reputation: 19391

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. However, if I have a SQL block, I can't find a way to make the code visible in the rendered file.

However, if I generate an html_document (standard knitr) instead of an html_notebook, the rendered HTML does include the SQL code (and output).

Is there a way to get the notebook output to do something closer to what the knit output does?

Upvotes: 4

Views: 279

Answers (1)

p0bs
p0bs

Reputation: 1034

I've also encountered this recently, Harlan, and began by asking if there's a way to get notebook output more like knit output.

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. 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.

Upvotes: 1

Related Questions