Learn R Programming

trud (version 0.2.0)

download_item: Download NHS TRUD item

Description

Downloads files for a specified NHS TRUD item. By default this downloads the latest release. Use the item numbers from trud_items() or get_subscribed_metadata().

Subscription Required

You must subscribe to TRUD items individually through the NHS TRUD website before you can access them using get_item_metadata() or download_item(). Simply having an API key is not sufficient. To see items you're already subscribed to, use get_subscribed_metadata(). To browse all available items, use trud_items().

Usage

download_item(
  item,
  directory = ".",
  file_type = c("archive", "checksum", "signature", "publicKey"),
  release = NULL,
  overwrite = FALSE
)

Value

The file path to the downloaded file, returned invisibly.

Arguments

item

An integer, the item to be downloaded. Get these from trud_items() or get_subscribed_metadata().

directory

Path to the directory to which this item will be downloaded to. This is set to the current working directory by default.

file_type

The type of file to download. Options are "archive" (the main release file), "checksum", "signature", or "publicKey". Defaults to "archive".

release

The release ID to be downloaded. Release IDs are found in the id field of each release from get_item_metadata(). If NULL (default), the latest item release will be downloaded.

overwrite

If TRUE, existing files will be overwritten. If FALSE (default), existing files will be skipped and the function will return the existing file path.

Working with specific releases

To download a specific (non-latest) release:

  1. Use get_item_metadata() with release_scope = "all" to retrieve metadata for all releases

  2. The release IDs are stored under the id item for each release

  3. Pass the desired release ID to the release parameter of download_item()

See Also

  • trud_items() to find item numbers

  • get_subscribed_metadata() to see items you can access

  • get_item_metadata() to explore available releases before downloading