get_country_by_calling_code {tidycountries} | R Documentation |
get_country_by_calling_code
Description
This function retrieves information about countries based on a specified calling code or part of it. The input can be a root calling code, suffix, or a full calling code, and the function is case-insensitive.
Usage
get_country_by_calling_code(call_code, geometry = FALSE)
Arguments
call_code |
A character string representing the calling code, root calling code, or suffix. The input is case-insensitive. |
geometry |
A logical value indicating whether to include geographic boundary data. Defaults to |
Value
A data frame containing the information of countries corresponding to the specified calling code, root, or suffixes.
If geometry = TRUE
, the result will include an additional column for geographic boundaries (as spatial features).
Note
The function utilizes the pre-loaded restcountries_data
dataset. Ensure that this dataset is loaded before invoking the function.
If geometry = TRUE
, the function joins with the world_administrative_boundaries
dataset, which must also be pre-loaded.
Examples
# Example usage: Find country information by root calling code
us_info <- get_country_by_calling_code("+1")
print(us_info)
# Example usage: Find country information by calling code suffix and include geometry
uk_info <- get_country_by_calling_code("44", geometry = TRUE)
print(uk_info)
# Example usage: Find country information by full calling code
india_info <- get_country_by_calling_code("+91")
print(india_info)