Learn R Programming

IndonesiAPIs (version 0.1.1)

get_country_info_idn: Get Key Country Information About Indonesia from the REST Countries API

Description

Retrieves selected, essential information about Indonesia using the REST Countries API. The function returns a tibble with core details such as population, area, capital, region, and official language(s).

See the API documentation at https://restcountries.com/. Example API usage: https://restcountries.com/v3.1/name/indonesia?fullText=true.

Usage

get_country_info_idn()

Arguments

Value

A tibble with the following 8 columns:

  • name_common: Common name of the country.

  • name_official: Official name of the country.

  • region: Geographical region.

  • subregion: Subregion within the continent.

  • capital: Capital city.

  • area: Area in square kilometers.

  • population: Population of the country.

  • languages: Languages spoken in the country, as a comma-separated string.

Returns NULL if the API is unavailable or returns an error.

Details

The function sends a GET request to the REST Countries API. If the API returns data for Indonesia, the function extracts and returns selected fields as a tibble. If the request fails or Indonesia is not found, it returns NULL and prints a message.

Examples

Run this code
# \donttest{
get_country_info_idn()
# }

Run the code above in your browser using DataLab