Is it an ISO 3166-1 country code?
Details
Case-insensitive lookup against the internal .iso3166_alpha2
table (built by data-raw/build_lookups.R from the ISOcodes package).
Note this overlaps is_us_state() for shared two-letter codes (e.g. MT);
guess_data_type()'s specificity ranking resolves such ties.
See also
Other code detectors:
is_ca_postal_code(),
is_http_status(),
is_roman(),
is_uk_postcode(),
is_unix_time(),
is_us_state(),
is_version(),
is_zip_code()
Examples
is_country_code(c("US", "gb", "ZZ", NA))
#> [1] TRUE TRUE FALSE NA