Skip to contents

This function retrieves information about a specific country based on its country code (cca2 or cca3) or common name. The function is case-insentive and provides a comprehensive overview of the selected country If "all" is passed as the input, it returns data for all countries. If the input does not match any country, the function returns a list of all available country names.

Usage

get_country_info(country_value)

Arguments

country_value

A character string representing the country code(cca2 or cca3) or common name. The input is case-insensitive. If "all" is passed, the function return data for all countries.

Value

A data frame with selected country information. If the input is "all", it returns data for all countries. if no match is found, a list of all available country names is printed.

Note

A data frame with selected country information. If the input is "all", it returns data for all countries. if no match is found, a list of all available country names is printed

Examples

# \donttest{
# Examples usage: Get information for Nigeria
nigeria_info <- get_country_info("Nigeria")
print(nigeria_info)
#> # A tibble: 1 × 19
#>   cca3  cca2  common_name official_name      capital region subregion continents
#>   <chr> <chr> <chr>       <chr>              <chr>   <chr>  <chr>     <chr>     
#> 1 NGA   NG    Nigeria     Federal Republic … Abuja   Africa Western … Africa    
#> # ℹ 11 more variables: un_member <lgl>, landlocked <lgl>, timezones <chr>,
#> #   start_of_week <chr>, car_side <chr>, currencies <chr>, population <int>,
#> #   area <dbl>, root <chr>, lat <dbl>, lon <dbl>

# Example usage: Get information for a country using it's cca2 code
usa_info <- get_country_info("US")
print(usa_info)
#> # A tibble: 1 × 19
#>   cca3  cca2  common_name   official_name    capital region subregion continents
#>   <chr> <chr> <chr>         <chr>            <chr>   <chr>  <chr>     <chr>     
#> 1 USA   US    United States United States o… Washin… Ameri… North Am… North Ame…
#> # ℹ 11 more variables: un_member <lgl>, landlocked <lgl>, timezones <chr>,
#> #   start_of_week <chr>, car_side <chr>, currencies <chr>, population <int>,
#> #   area <dbl>, root <chr>, lat <dbl>, lon <dbl>
# }