Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I suppress this output?

Tags:

r

rstudio

I have a code chunk in an R Markdown file.

```{r}
library(UsingR)
```

Using knitHTML to compile causes the following output, which never happened before I updated to the latest versions of R and RStudio:

## Loading required package: MASS
## Loading required package: HistData
## Loading required package: Hmisc
## Loading required package: grid
## Loading required package: lattice
## Loading required package: survival
## Loading required package: splines
## Loading required package: Formula
## 
## Attaching package: 'Hmisc'
## 
## The following objects are masked from 'package:base':
## 
##     format.pval, round.POSIXt, trunc.POSIXt, units
## 
## Loading required package: aplpack
## Loading required package: tcltk
## Loading required package: quantreg
## Loading required package: SparseM
## 
## Attaching package: 'SparseM'
## 
## The following object is masked from 'package:base':
## 
##     backsolve
## 
## 
## Attaching package: 'quantreg'
## 
## The following object is masked from 'package:Hmisc':
## 
##     latex
## 
## The following object is masked from 'package:survival':
## 
##     untangle.specials
## 
## 
## Attaching package: 'UsingR'
## 
## The following object is masked from 'package:survival':
## 
##     cancer

How can I suppress this output? Note: echo=FALSE did not work.

like image 393
David Avatar asked Aug 23 '14 22:08

David


1 Answers

Setting message=FALSE in your code chunk should work.

```{r, message=FALSE}
library(UsingR)
```

Setting echo=FALSE should not have worked - this is by design. The echo parameter in the code chunk controls the display of the code inside the chunk (i.e. library(UsingR)).

Messages (as shown) are handled separately through the message parameter.

Errors are handled through the error parameter (i.e. error=FALSE will suppress error messages).

Results are handled through the results parameter (i.e. results=FALSE will suppress the results of the code chunk).

Warnings are handled through the warning parameter (i.e. warning=FALSE will suppress the warnings generated by the code chunk) as warnings are distinct from errors.

There are many other code-chunk parameters available, but these are the main parameters governing the text-based output generated by a given code-chunk.

like image 152
joemienko Avatar answered Oct 24 '22 21:10

joemienko