Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
203 views
in Technique[技术] by (71.8m points)

R - Markdown avoiding package loading messages

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':

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can use include=FALSE to exclude everything in a chunk.

```{r include=FALSE}
source("C:/Rscripts/source.R")
```

If you only want to suppress messages, use message=FALSE instead:

```{r message=FALSE}
source("C:/Rscripts/source.R")
```

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...