A.L.
A.L.

Reputation: 21

How to suppress downloading progress in HTML file

I am using imfr package to download some IMF data series

library(imfr)
t <- imf_data(database_id = "BOP", indicator = "BCA_BP6_USD", 
                             country = "all", start = "1990", freq = "Q")

I prespecified certain parameters in a separate chunk before to suppress downloading progress

downloading progress

knitr::opts_chunk$set(echo = FALSE, message = FALSE, warning = FALSE, error = FALSE, results = 'hide', fig.keep = 'all')

However, neither of these options did the job. Moreover results = 'hide' suppressed all the output including text and figures.

How can I solve this issue without having a separate chunk for data downloading?

Upvotes: 2

Views: 207

Answers (1)

Shafee
Shafee

Reputation: 19937

You can capture all those downloads message and progress bar in capture.output and wrap it with invisible. (Got this idea from this question and answer on SO).

And then make a wrapper function imf_data which works the same (mask the imfr::imf_data function) but does not print all those download messages and the progress bar.

---
title: "IMF Data"
output: html_document
---


```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE)

imf_data <- function(...) {
  invisible(capture.output(dt <- imfr::imf_data(...)))
  return(dt)
}
```


```{r}
library(imfr)

t <- imf_data(database_id = "BOP", indicator = "BCA_BP6_USD", 
                             country = "all", start = "1990", freq = "Q")
```


```{r, comment=""}
head(t)
```

IMF data output without a progress bar


Upvotes: 1

Related Questions