View source: R/get_archive_data.R
get_archive_data | R Documentation |
Downloads compressed archive files from a URL and extracts their contents to a specified directory. Supports multiple archive formats and handles permission confirmation.
get_archive_data(url, target_dir, force = FALSE, confirmed = FALSE)
url |
Character string. Full URL to the compressed archive file. |
target_dir |
Character string. Directory where the archive contents should be extracted. |
force |
Logical. If TRUE, overwrites existing data in target directory. Default is FALSE. |
confirmed |
Logical. If TRUE, skips permission confirmation prompt. Useful for reproducible workflows. Default is FALSE. |
Supported archive formats:
ZIP (.zip)
Gzip (.gz)
Tar (.tar)
Compressed tar (.tgz)
The function includes safety features:
Permission confirmation for data usage
Directory existence checks
Archive format validation
Automatic file cleanup
Invisible NULL. Called for side effects:
Downloads archive file
Creates target directory if needed
Extracts archive contents
Cleans up temporary files
## Not run:
data_dir <- file.path(tempdir(), "data")
url <-
"https://raw.githubusercontent.com/qtalr/qtkit/main/inst/extdata/test_data.zip"
get_archive_data(
url = url,
target_dir = data_dir,
confirmed = TRUE
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.