Title: | Seamless Access to World Bank International Debt Statistics (IDS) |
Version: | 1.0.0 |
Description: | Access and analyze the World Bank's International Debt Statistics (IDS) https://datacatalog.worldbank.org/search/dataset/0038015. IDS provides creditor-debtor relationships between countries, regions, and institutions. 'wbids' enables users to download, process and work with IDS series across multiple geographies, counterparts, and time periods. |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
Depends: | R (≥ 4.1.0) |
Imports: | cli, withr, httr2 (≥ 1.0.0), dplyr (≥ 1.0.0), purrr (≥ 1.0.0), tidyr (≥ 1.0.0), rlang (≥ 1.0.0), mime |
Suggests: | curl, jsonlite, tibble, quarto, readxl (≥ 1.0.0), testthat (≥ 3.0.0), httr |
Config/testthat/edition: | 3 |
URL: | https://teal-insights.github.io/r-wbids/, https://github.com/teal-insights/r-wbids/ |
BugReports: | https://github.com/teal-insights/r-wbids/issues |
VignetteBuilder: | quarto |
NeedsCompilation: | no |
Packaged: | 2025-02-01 15:00:25 UTC; chriscarrollsmith |
Author: | Teal Emery [aut, cre],
Teal Insights [cph],
Christoph Scheuch |
Maintainer: | Teal Emery <lte@tealinsights.com> |
Repository: | CRAN |
Date/Publication: | 2025-02-08 22:50:02 UTC |
wbids: Seamless Access to World Bank International Debt Statistics (IDS)
Description
Access and analyze the World Bank's International Debt Statistics (IDS) https://datacatalog.worldbank.org/search/dataset/0038015. IDS provides creditor-debtor relationships between countries, regions, and institutions. 'wbids' enables users to download, process and work with IDS series across multiple geographies, counterparts, and time periods.
Author(s)
Maintainer: Teal Emery lte@tealinsights.com
Authors:
Christoph Scheuch christoph@tidy-intelligence.com (ORCID)
Other contributors:
Teal Insights [copyright holder]
Christopher Smith chriscarrollsmith@gmail.com [contributor]
See Also
Useful links:
Report bugs at https://github.com/teal-insights/r-wbids/issues
Internal Counterparts Data
Description
This dataset is accessible through ids_list_counterparts.
Usage
counterparts
Format
An object of class tbl_df
(inherits from tbl
, data.frame
) with 303 rows and 5 columns.
Internal Geographies Data
Description
This dataset is accessible through ids_list_geographies.
Usage
geographies
Format
An object of class tbl_df
(inherits from tbl
, data.frame
) with 136 rows and 14 columns.
Download and Process Bulk Data File for International Debt Statistics
Description
This function downloads a data file from the World Bank International Debt Statistics (IDS), reads and processes the data into a tidy format.
Usage
ids_bulk(
file_url,
file_path = tempfile(fileext = ".xlsx"),
quiet = FALSE,
timeout = getOption("timeout", 60),
warn_size = TRUE
)
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 |
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
## Not run:
available_files <- ids_bulk_files()
data <- ids_bulk(
available_files$file_url[1]
)
## End(Not run)
Retrieve Available Bulk Download Files for International Debt Statistics
Description
This function returns a tibble with metadata for files available for bulk download via the World Bank International Debt Statistics (IDS). It includes information such as file names, URLs, and the last update dates for each file in Excel (xlsx) format.
Usage
ids_bulk_files()
Value
A tibble containing the available files and their metadata:
- file_name
The name of the file available for download.
- file_url
The URL to download the file in Excel format.
- last_updated_date
The date when the file was last updated.
Examples
ids_bulk_files()
Retrieve Bulk Series Metadata for International Debt Statistics
Description
This function retrieves a tibble with metadata for series available via bulk download of the World Bank International Debt Statistics (IDS).
Usage
ids_bulk_series()
Value
A tibble containing the available series and their metadata:
- series_id
The unique identifier for the series (e.g., "BN.CAB.XOKA.CD").
- series_name
The name of the series (e.g., "Current account balance (current US$)").
- source_id
The ID of the data source providing the indicator.
- source_name
The name or description of the source of the indicator data.
- source_note
Additional notes or descriptions about the data source.
- source_organization
The organization responsible for the data source.
Examples
ids_bulk_series()
Fetch Data from the World Bank International Debt Statistics (IDS) API
Description
Retrieves standardized debt statistics from the World Bank's International Debt Statistics (IDS) database, which provides comprehensive data on the external debt of low and middle-income countries. The function handles country identification, data validation, and unit standardization, making it easier to conduct cross-country debt analysis and monitoring.
Usage
ids_get(
geographies,
series,
counterparts = "WLD",
start_year = 2000,
end_year = NULL,
progress = FALSE
)
Arguments
geographies |
A character vector of geography identifiers representing
debtor countries and aggregates. Must use
|
series |
A character vector of debt statistics series identifiers that
must match the |
counterparts |
A character vector of creditor identifiers that must
match the
|
start_year |
A numeric value representing the starting year (default: 2000). This default is intended to reduce data volume. For historical analysis, explicitly set to 1970 (the earliest year of data available). |
end_year |
A numeric value representing the ending year (default: NULL). Must be >= 1970 and cannot be earlier than start_year. If NULL, returns data through the most recent available year. Some debt service-related series include projections of debt service. For the 2024 data release, debt service projections are available through 2031. |
progress |
A logical value indicating whether to display progress messages during data retrieval (default: FALSE). |
Value
A tibble containing debt statistics with the following columns:
- geography_id
The identifier for the debtor geography (e.g., "GHA" for Ghana, "LIC" for low income countries)
- series_id
The identifier for the debt statistic series (e.g., "DT.DOD.DECT.CD" for total external debt stocks)
- counterpart_id
The identifier for the creditor (e.g., "WLD" for world total, "730" for China)
- year
The year of the observation
- value
The numeric value of the debt statistic, standardized to the units specified in the series definition (typically current US dollars)
Data Coverage and Validation
The IDS database provides detailed debt statistics for low and middle-income countries, including:
Debt stocks and flows
Debt service and interest payments
Creditor composition
Terms and conditions of new commitments
To ensure valid queries:
Use ids_list_geographies to find valid debtor geography codes
Use ids_list_series to explore available debt statistics
Use ids_list_counterparts to see available creditor codes
See Also
-
ids_list_geographies()
for available debtor geography codes -
ids_list_series()
for available debt statistics series codes -
ids_list_counterparts()
for available creditor codes
Examples
# Get total external debt stocks for a single country from 2000 onward
ghana_debt <- ids_get(
geographies = "GHA",
series = "DT.DOD.DECT.CD" # External debt stocks, total
)
# Compare debt service metrics across income groups
income_groups <- ids_get(
geographies = c("LIC", "LMC", "UMC"), # Income group aggregates
series = "DT.TDS.DECT.CD", # Total debt service
start_year = 2010
)
# Analyze debt composition by major creditors
creditor_analysis <- ids_get(
geographies = c("KEN", "ETH"), # Kenya and Ethiopia
series = c(
"DT.DOD.DECT.CD", # Total external debt
"DT.TDS.DECT.CD" # Total debt service
),
counterparts = c(
"WLD", # World total
"730", # China
"907", # IMF
"BND" # Bondholders
),
start_year = 2015
)
List Available Counterparts from the World Bank International Debt Statistics API
Description
This function returns a tibble with available counterparts from the World Bank International Debt Statistics (IDS) API. Each row provides details on counterparts, including their unique identifiers, names, and types.
Usage
ids_list_counterparts()
Value
A tibble containing the available counterparts and their attributes:
- counterpart_id
The unique identifier for the counterpart (e.g., "730").
- counterpart_name
The standardized name of the counterpart (e.g., "China").
- counterpart_iso2code
ISO 3166-1 alpha-2 code of the counterpart (e.g., "CN").
- counterpart_iso3code
ISO 3166-1 alpha-3 code of the counterpart (e.g., "CHN").
- counterpart_type
The type of counterpart (e.g., "Country", "Institution", "Region").
Examples
ids_list_counterparts()
List Available Geographies from the World Bank International Debt Statistics API
Description
This function returns a tibble with available geographies from the World Bank International Debt Statistics (IDS) API. Each row provides details on geographies, including their unique identifiers, names, and types.
Usage
ids_list_geographies()
Value
A tibble containing the available geographies and their attributes:
- geography_id
ISO 3166-1 alpha-3 code of the geography (e.g., "ZMB").
- geography_name
The standardized name of the geography (e.g., "Zambia").
- geography_iso2code
ISO 3166-1 alpha-2 code of the geography (e.g., "ZM").
- geography_type
The type of geography (e.g., "Country", "Region").
- capital_city
The capital city of the geography (e.g., "Lusaka").
- region_id
The unique identifier for the region (e.g., "SSF").
- region_iso2code
ISO 3166-1 alpha-2 code of the region (e.g., "ZG").
- region_name
The name of the region (e.g., "Sub-Saharan Africa").
- admin_region_id
The unique identifier for the administrative region (e.g., "SSA").
- admin_region_iso2code
The ISO 3166-1 alpha-2 code for the administrative region (e.g., "ZF").
- admin_region_name
The name of the administrative region (e.g., "Sub-Saharan Africa (excluding high income)").
- lending_type_id
The unique identifier for the lending type (e.g., "IDX").
- lending_type_iso2code
ISO code for the lending type (e.g., "XI").
- lending_type_name
The name of the lending type (e.g., "IDA").
Examples
ids_list_geographies()
List Available Series from the World Bank International Debt Statistics API
Description
This function returns a tibble with available series from the World Bank International Debt Statistics (IDS) API. Each series provides data on various debt-related indicators.
Usage
ids_list_series()
Value
A tibble containing the available series and their metadata:
- series_id
The unique identifier for the series (e.g., "BN.CAB.XOKA.CD").
- series_name
The name of the series (e.g., "Current account balance (current US$)").
- source_id
The ID of the data source providing the indicator.
- source_name
The name or description of the source of the indicator data.
- source_note
Additional notes or descriptions about the data source.
- source_organization
The organization responsible for the data source.
Examples
ids_list_series()
List Available Series-Topic combinations from the World Bank International Debt Statistics API
Description
This function returns a tibble with available series-topic combinations from the World BankInternational Debt Statistics (IDS) API. Each row provides a mapping from series to topic, with the possibility of multiple topic per series.
Usage
ids_list_series_topics()
Value
A tibble containing the available series and their topics:
- series_id
The unique identifier for the series (e.g., "BM.GSR.TOTL.CD").
- topic_id
The unique identifier for the topic (e.g., 3).
- topic_name
The name of the topic (e.g., "External Debt").
Examples
ids_list_series_topics()
Read Bulk Information from World Bank Data Catalog API
Description
Internal function to retrieve bulk download information for International Debt Statistics (IDS) from the World Bank Data Catalog API.
Usage
read_bulk_info()
Value
A list containing metadata about available bulk downloads
Internal Series Data
Description
This dataset is accessible through ids_list_series.
Usage
series
Format
An object of class tbl_df
(inherits from tbl
, data.frame
) with 572 rows and 6 columns.
Internal Series-Topics Data
Description
This dataset is accessible through ids_list_series_topics.
Usage
series_topics
Format
An object of class tbl_df
(inherits from tbl
, data.frame
) with 598 rows and 3 columns.