Learn R Programming

xfun (version 0.48)

download_file: Try various methods to download a file

Description

Try all possible methods in download.file() (e.g., libcurl, curl, wget, and wininet) and see if any method can succeed. The reason to enumerate all methods is that sometimes the default method does not work, e.g., https://stat.ethz.ch/pipermail/r-devel/2016-June/072852.html.

Usage

download_file(
  url,
  output = url_filename(url),
  ...,
  .error = "No download method works (auto/wininet/wget/curl/lynx)"
)

Value

The integer code 0 for success, or an error if none of the methods work.

Arguments

url

The URL of the file.

output

Path to the output file. By default, it is determined by url_filename().

...

Other arguments to be passed to download.file() (except method).

.error

An error message to signal when the download fails.