Skip to contents

Maps UN M49 numeric area codes to ISO 3166-1 alpha-3 country codes using the who_countries dataset shipped with DSIR. Counterpart to iso3_to_m49() and used internally by sdg_clean() to populate the iso3 column on SDG output.

Usage

m49_to_iso3(m49)

Arguments

m49

Character vector of M49 codes.

Value

A character vector the same length as m49. Non-Member codes (region aggregates, non-Member areas) return NA.

Details

M49 codes that do not correspond to a WHO Member State return NA. This includes region / world aggregates (e.g. "900" for World, "001" for World, "419" for Latin America and the Caribbean) and codes for non-Member areas (e.g. Puerto Rico, Tokelau).

Input accepts either the zero-padded form ("076") or the bare form ("76"); both are normalised before lookup. Non-numeric input returns NA (with a single warning from the underlying as.integer() coercion).

Examples

m49_to_iso3(c("608", "250", "392"))
#> [1] "PHL" "FRA" "JPN"
# "PHL" "FRA" "JPN"

# Zero-padded and bare forms both accepted
m49_to_iso3(c("076", "76"))
#> [1] "BRA" "BRA"
# "BRA" "BRA"

# Non-Member areas / aggregates return NA
m49_to_iso3(c("900", "608"))
#> [1] NA    "PHL"
# NA "PHL"