Alex Rivera | Logout

Remove Hashes in R Output from R Markdown and Knitr

Asked 2013-02-26T04:12:11.393
81

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

Edit
Report

1 Answer

132

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)
```
answered 2013-02-26T04:14:25.790

Your Answer