Skip to contents

Download TRS files

Usage

download_trs(url, path, path_noid)

Arguments

url

URL of the TRS file

path

Path to save the TRS file

path_noid

Path to save the TRS file without the ID

Value

Path to the downloaded file

Examples

jecfa_sample <- c(1, 10, 11) |>
  purrr::map(\(id) compose_jecfa_list(id) |> get_result()) |>
  create_df() |>
  process_df() |>
  add_metadata()

trs_urls_list <- jecfa_sample |>
  compose_urls() |>
  remove_null_urls()
#> Warning: Condition not satisfied, skipping...

trs_urls <- trs_urls_list |>
  purrr::map_chr("url")

out_dir <- file.path(tempdir(), "trs")
dir.create(out_dir)
trs_paths <- trs_urls_list |>
  compose_filepaths(out_dir)

out_dir_noid <- file.path(tempdir(), "trs_noid")
dir.create(out_dir_noid)
trs_paths_noid <- trs_urls_list |>
  compose_filepaths(out_dir_noid, noid = TRUE)

if (FALSE) { # this would actually download the data
  download_trs(trs_urls[[1]], trs_paths[[1]], trs_paths_noid[[1]])
  fs::dir_ls(out_dir)
  fs::dir_ls(out_dir_noid)
}