Link to my website

Learning objective

Case study: loading tidyverse

If you try to load the tidyverse package, you get many messages.

library(tidyverse)
## ── Attaching packages ────────────── tidyverse 1.2.1 ──
## ✔ ggplot2 3.2.1     ✔ purrr   0.3.2
## ✔ tibble  2.1.3     ✔ dplyr   0.8.3
## ✔ tidyr   1.0.0     ✔ stringr 1.4.0
## ✔ readr   1.3.1     ✔ forcats 0.4.0
## ── Conflicts ───────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()

In writing your report, you probably do not want to

  1. print the R code; and
  2. print all the peripheral messages.

To achieve this you can use the chunk option:

echo = FALSE, message = FALSE.

Can you tell which option does what?

🔧 Modify the pkg-load chunk to hide the code and message outputs.

This can be done more succintly using:

include = FALSE.

In fact it’s equivalent to hiding code and all outputs:

echo=FALSE, results='hide', message=FALSE, warning=FALSE, fig.show='hide'.

Reference: Yihui has excellent tips like this on his blog.