Reputation: 12074
Say I have the following RMarkdown file:
---
title: "Test"
author: "Mr. Test"
date: "October 15, 2018"
output: html_document
---
```{r echo = FALSE, message = FALSE, error = FALSE, warning = FALSE}
# Load library
library(marmap)
# Download bathymetry data and keep for future use
bathy <- getNOAA.bathy(lon1 = -5, lon2 = 5, lat1 = -5, lat2 = 5, resolution = 1, keep = TRUE)
# Perform same command again, which reads downloaded file
invisible(bathy <- getNOAA.bathy(lon1 = -5, lon2 = 5, lat1 = -5, lat2 = 5, resolution = 1, keep = TRUE))
```
This uses the marmap
package to download and load some data into R. Then, it loads the data again from the local file. This gives the following output:
Notice that I try suppressing all output from this chunk using chunk options, whether an error, message, or warning, yet there is still output. I even tried wrapping the commands in invisible
and still I get output. Looking at the raw code for getNOAA.bathy
, I see that the author is using cat
to print output rather than message
. In this case, how do I silence the function?
Upvotes: 0
Views: 43
Reputation: 12074
Okay, I have a solution. Apparently, invisible
alone won't do the job, but invisible(capture.output())
will. Any clarification as to why this is the case would be appreciated.
Upvotes: 2