Remove Hashes in R Output from R Markdown and Knitr

mchangun picture mchangun · Feb 26, 2013 · Viewed 32.4k times · Source

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)
```

enter image description here

Answer

Gary Weissman picture Gary Weissman · Feb 26, 2013

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)
```