Returns specified information about countries based on their ISO3 codes. The function accepts a vector of ISO codes and returns corresponding information based on the specified option.
Arguments
- iso
Character vector of ISO3 country codes
- opt
Character string specifying the type of information to return. Options:
"Name": Country names
"ISO2": ISO2 country codes
"Region": Major geographical regions (AFRICA, AMERICAS, ASIA, EUROPE, OCEANIA)
"Subregion": Detailed geographical regions (e.g., NORTH_AFRICA, WEST_ASIA)
"Center-Periphery": Economic category (CTR_LDR, CTR_FOL, SMP_LDR, SMP_FOL, PERI)
"Oil": Hydrocarbon status (HYD_EXP, HYD_IMP, or NA)
"NaturalRent": Natural resource status (NRS_REN or NA)
"Category": All categories the country belongs to
- verbose
Logical, whether to print informative messages about special cases (default: TRUE)
Value
A character vector of the same length as the input iso vector containing the requested information. For "Category" option, returns a character vector of categories for each ISO code. For "ISO2" option, returns ISO2 codes (e.g., "US" for "USA"). Returns NA for countries not found in the specified category or for invalid ISO codes.
See also
wp_ctry2iso
for converting country names to ISO codes,
wp_get_category
for getting all countries in specific categories
Other country code conversion functions:
wp_ctry2iso()
Other country classification functions:
wp_get_category()
Examples
# Get country names
wp_from_iso(c("USA", "FRA", "DEU"), "Name")
#> USA FRA DEU
#> "United States" "France" "Germany"
# Get ISO2 codes
wp_from_iso(c("USA", "GBR", "FRA"), "ISO2") # Returns c("US", "GB", "FR")
#> USA GBR FRA
#> "US" "GB" "FR"
# Get regions
wp_from_iso(c("CHN", "BRA"), "Region")
#> CHN BRA
#> "ASIA" "AMERICAS"
# Get oil status
wp_from_iso(c("SAU", "USA", "RUS"), "Oil") # Returns c("HYD_EXP", NA, "HYD_EXP")
#> SAU USA RUS
#> "HYD_EXP" NA "HYD_EXP"
# Get economic categories
wp_from_iso(c("USA", "CHN", "ETH"), "Center-Periphery")
#> USA CHN ETH
#> "CTR_LDR" "SMP_LDR" "PERI"