download_data: Download a File

View source: R/lib_data_loader.R

download_dataR Documentation

Download a File

Description

Thin wrapper around utils::download.file() that returns the target path invisibly so it composes in pipelines.

Usage

download_data(url, target_path, mode = "wb", quiet = FALSE)

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.

Value

The target_path, returned invisibly.

Examples


# 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)


rmoriebricklayer documentation built on Aug. 5, 2026, 9:08 a.m.