0

I want to supress an error message of download.file function in an Rmarkdown document. I tried results="hide",message=F,echo=F, i tried invisible, sink, suppressWarnings,suppressMessages,options(error = expression(NULL)), without luck. Here is my example:

```{r,results="hide",message=F,echo=F}

tryCatch(download.file(paste0("https://www.kjqhfkpuc.es"),
                destfile = paste0("report.pdf"),mode = "wb",quiet = T),error = function(e) e)


```

I want no output in my document

denis
  • 5,580
  • 1
  • 13
  • 40

1 Answers1

1

Adding options(warn = -1) to the start of your code chunk will suppress the warnings globally. However it is usally a good idea to turn warnings back on afterwards with your previous warning setting.

```{r,results="hide",message=F,echo=F}

oldw <- getOption("warn")
options(warn = -1)
tryCatch(download.file(paste0("https://www.kjqhfkpuc.es"),
            destfile = paste0("report.pdf"),mode = "wb",quiet = T),error = function(e) e)

options(warn = oldw)

```

See this question

hfshr
  • 118
  • 1
  • 7