Remove Hashes in R Output from R Markdown and Knitr

knitr, r-markdown

Solution

You can include in your chunk options something like

comment=NA # to remove all hashes

or

comment='%' # to use a different character

More help on knitr available from here: http://yihui.name/knitr/options

If you are using R Markdown as you mentioned, your chunk could look like this:

{r comment=NA} summary(cars)

`

If you want to change this globally, you can include a chunk in your document:

{r include=FALSE} knitr::opts_chunk$set(comment = NA)

`

Problem

I am using RStudio to write my R Markdown files. How can I remove the hashes (`##`) in the final HTML output file that are displayed before the code output? As an example: ```` --- output: html_document --- ```{r} head(cars) ``` ````

Original source