Skip to contents

Downloads compressed archive files from a URL and extracts their contents to a specified directory. Supports multiple archive formats and handles permission confirmation.

Usage

get_archive_data(url, target_dir, force = FALSE, confirmed = FALSE)

Arguments

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.

Value

Invisible NULL. Called for side effects:

  • Downloads archive file

  • Creates target directory if needed

  • Extracts archive contents

  • Cleans up temporary files

Details

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

Examples

if (FALSE) { # \dontrun{
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
)
} # }