graceful_download | R Documentation |
Attempts to download a file from a specified URL, retrying a set number of times if the download fails. This function meets CRAN's requirement for gracefully handling the use of internet resources by catching errors and returning a warning message if the download ultimately fails.
graceful_download(url, destfile, retries = 3)
url |
Character. The URL of the file to download. |
destfile |
Character. The path to the destination file where the downloaded content will be saved. |
retries |
Integer. The maximum number of download attempts (default is 3). |
Logical. Returns 'TRUE' if the download succeeds, 'FALSE' otherwise.
## Not run:
dataset_url <- "https://example.com/dataset.csv"
tmp <- tempfile(fileext = ".csv")
success <- download_file_gracefully(dataset_url, tmp)
if (!success) {
message("Continuing gracefully without the dataset.")
}
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.