Thin wrapper around
utils::download.file() that returns
the target path invisibly so it composes in pipelines.
Arguments
- url
URL to download.
- target_path
Destination path on disk.
- mode
Write mode passed to
utils::download.file(); defaults to"wb"(binary) for cross-platform safety.- quiet
Logical; suppress progress output. Defaults to
FALSE.
Examples
# \donttest{
# try(): a live download must fail gracefully on an offline check machine.
dest <- try(download_data("https://cloud.r-project.org/",
tempfile(fileext = ".html"), quiet = TRUE))
if (!inherits(dest, "try-error")) file.exists(dest)
#> [1] TRUE
# }