Learn R Programming

nadaverse (version 0.1.0)

catalogs: Small Helper Functions for Data Catalog Access

Description

A suite of small helper functions designed to interact with and retrieve essential metadata from various international organization data repositories (catalogs). These functions standardize the process of obtaining lists of available data access codes, collections, country codes, and latest entries from specified sources.

Usage

catalogs(show = TRUE)

access_codes(catalog)

collections(catalog)

country_codes(catalog)

latest_entries(catalog, limit = NULL)

metadata(catalog, id)

Value

A data frame containing the requested metadata, except for metadata(), which returns a list. The structure of the returned object varies by function:

  • access_codes: Returns a data frame with columns related to data resource identifiers (e.g., code, description).

  • collections: Returns a data frame detailing data groupings (e.g., collection_id, name).

  • country_codes: Returns a data frame of standard country identifiers (e.g., iso3c, country_name).

  • latest_entries: Returns a data frame of the most recently added datasets or entries, with columns reflecting their general metadata (e.g., title, date_added).

  • metadata: Returns a list of the study metadata including detailed description, abstract, sampling methodology, and other study-specific details.

If the API call fails or no data is found, the function may return an empty data frame or raise an error.

Arguments

show

Logical. If TRUE, prints supported catalogs to console

catalog

A required character string specifying the name of the data catalog (e.g., "fao", "ilo", "wb") from which to retrieve metadata.

limit

A positive integer number, applicable only to latest_entries, indicating the maximum number of results (data entries) to return. If NULL or omitted, a default limit set by the API will be used.

id

A required study identifier. Accepts either the numeric Study ID (integer, e.g., 101) or the character Study ID Number (string, e.g., "ALB_2012_LSMS_v01_M_v01_A_PUF"). These values are typically returned in the search results from search_catalog(), latest_entries() or data_files().

Supported Catalogs

The catalog argument must be one of the following short codes (case-insensitive) corresponding to the respective microdata repository. The list is sorted alphabetically by code.

Author

Gutama Girja Urago

Details

All functions require a valid catalog name. The functions communicate with a backend API (implied by base_url and get_response) to fetch the requested data in a standardized format. The validity of the catalog is checked internally using assert_catalog.

See Also

The main search function: search_catalog

Examples

Run this code
if (FALSE) {
# --- Examples for Supported Catalogs ---

# 1. Data First (df): Get available access codes.
df_codes <- access_codes("df")

# 2. Economic Research Forum (erf): Get latest data entries (limited to 5).
erf_latest <- latest_entries("erf", limit = 5)

# 3. Food and Agriculture Organization (fao): Get available collections.
fao_collections <- collections("fao")

# 4. International Household Survey Network (ihsn): Get supported country codes.
ihsn_countries <- country_codes("ihsn")

# 5. International Labour Organization (ilo): Get available access codes.
ilo_codes <- access_codes("ilo")

# 6. Government of India (india): Get latest data entries (limited to 10).
india_latest <- latest_entries("india", limit = 10)

# 7. United Nations High Commissioner for Refugees (unhcr): Get available collections.
unhcr_collections <- collections("unhcr")

# 8. The World Bank (wb): Get supported country codes.
wb_countries <- country_codes("wb")

# Example for the metadata function (requires a study ID)
wb_study_metadata <- metadata("wb", id = 8098)
str(wb_study_metadata)
}

Run the code above in your browser using DataLab