One frequently asked question about knitr is how to hide package loading messages. For example, when you or library(ggplot2)
, you may see some loading messages. Such messages can also be suppressed by the chunk option message = FALSE
.
```{r, echo=c(4, 5), message=c(1, 2), warning=2:3}
# one way to generate random N(0, 1) numbers
x <- qnorm(runif(10))
x <- rnorm(10)
for (i in 1:5) warning('Here is the warning ', i)
```
You can use negative indices, too. For example, echo = -2
means to exclude the second expression of the source code in the output.
For source code blocks in the html_document
output, if you do not want to completely omit them (echo = FALSE
), you may see Section for how to fold them on the page, and allow users to unfold them by clicking the unfolding buttons.