本文介绍了R-Markdown避免加载包消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直通过R-Studio使用Knitr,并且认为它非常简洁.我有一个小问题.当我在R-Chunk中获取文件时,knitr输出包括如下外部注释:
I have been using Knitr via R-Studio, and think it is pretty neat. I have a minor issue though. When I source a file in an R-Chunk, the knitr output includes external comments as follows:
+ FALSE Loading required package: ggplot2
+ FALSE Loading required package: gridExtra
+ FALSE Loading required package: grid
+ FALSE Loading required package: VGAM
+ FALSE Loading required package: splines
+ FALSE Loading required package: stats4
+ FALSE Attaching package: 'VGAM'
+ FALSE The following object(s) are masked from 'package:stats4':
我试图以各种方式设置R-chunk选项,但似乎仍无法避免该问题:
I have tried to set R-chunk options in various ways but still didn't seem to avoid the problem:
```{r echo=FALSE, cache=FALSE, results=FALSE, warning=FALSE, comment=FALSE, warning=FALSE}
source("C:/Rscripts/source.R");
```
有什么办法可以注释掉这些消息?
Is there any way to comment out these messages?
推荐答案
您可以使用include=FALSE
排除块中的所有内容.
You can use include=FALSE
to exclude everything in a chunk.
```{r include=FALSE}
source("C:/Rscripts/source.R")
```
如果只想禁止显示消息,请改用message=FALSE
:
If you only want to suppress messages, use message=FALSE
instead:
```{r message=FALSE}
source("C:/Rscripts/source.R")
```
这篇关于R-Markdown避免加载包消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!