Download and Process Bulk Data File for International Debt Statistics
Source:R/ids_bulk.R
ids_bulk.Rd
This function downloads a data file from the World Bank International Debt Statistics (IDS), reads and processes the data into a tidy format.
Arguments
- file_url
A character string specifying the URL of the Excel file to download. This parameter is required (see ids_bulk_files).
- file_path
An optional character string specifying the file path where the downloaded file will be saved. Defaults to a temporary file with
.xlsx
extension. The file will automatically be deleted after processing.- quiet
A logical parameter indicating whether messages should be printed to the console.
- timeout
An integer specifying the timeout in seconds for downloading the file. Defaults to the current R timeout setting.
- warn_size
A logical parameter indicating whether to warn about large downloads. Defaults to TRUE.
Value
A tibble containing processed debt statistics data with the following columns:
- geography_id
The unique identifier for the geography (e.g., "ZMB").
- series_id
The unique identifier for the series (e.g., "DT.DOD.DPPG.CD").
- counterpart_id
The unique identifier for the counterpart series.
- year
The year corresponding to the data (as an integer).
- value
The numeric value representing the statistic for the given geography, series, counterpart, and year.
Examples
# \donttest{
available_files <- ids_bulk_files()
data <- ids_bulk(
available_files$file_url[1]
)
#> Warning: This file is 125.8 MB and may take several minutes to download. Current timeout
#> setting: 60 seconds. Use `warn_size = FALSE` to disable this warning.
#> Downloading file to: /tmp/RtmpMuojbI/file537cb222df7.xlsx
#> Reading in file.
#> Processing file.
# }