从R Markdown和Knitr移除R输出中的哈希 [英] Remove Hashes in R Output from R Markdown and Knitr

查看:73
本文介绍了从R Markdown和Knitr移除R输出中的哈希的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用RStudio编写我的R Markdown文件.如何在代码输出之前显示的最终HTML输出文件中删除哈希(##)?

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?

例如:

---
output: html_document
---

```{r}
head(cars)
```

推荐答案

您可以在块选项中包含类似内容

You can include in your chunk options something like

comment=NA # to remove all hashes

comment='%' # to use a different character

有关编织器的更多帮助,请参见: http://yihui.name/knitr/options

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

如果您使用的是R Markdown,那么您的代码块可能看起来像这样:

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

这篇关于从R Markdown和Knitr移除R输出中的哈希的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆