% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/m49_to_iso3.R
\name{m49_to_iso3}
\alias{m49_to_iso3}
\title{Convert UN M49 Numeric Codes to ISO3 Codes}
\usage{
m49_to_iso3(m49)
}
\arguments{
\item{m49}{Character vector of M49 codes.}
}
\value{
A character vector the same length as \code{m49}. Non-Member
codes (region aggregates, non-Member areas) return \code{NA}.
}
\description{
Maps UN M49 numeric area codes to ISO 3166-1 alpha-3 country codes
using the \code{\link{who_countries}} dataset shipped with DSIR. Counterpart
to \code{\link[=iso3_to_m49]{iso3_to_m49()}} and used internally by \code{\link[=sdg_clean]{sdg_clean()}} to populate
the \code{iso3} column on SDG output.
}
\details{
M49 codes that do not correspond to a WHO Member State return \code{NA}.
This includes region / world aggregates (e.g. \code{"900"} for World,
\code{"001"} for World, \code{"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 (\code{"076"}) or the bare
form (\code{"76"}); both are normalised before lookup. Non-numeric
input returns \code{NA} (with a single warning from the underlying
\code{\link[=as.integer]{as.integer()}} coercion).
}
\examples{
m49_to_iso3(c("608", "250", "392"))
# "PHL" "FRA" "JPN"

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

# Non-Member areas / aggregates return NA
m49_to_iso3(c("900", "608"))
# NA "PHL"
}
\seealso{
\code{\link{who_countries}}, \code{\link[=iso3_to_m49]{iso3_to_m49()}}, \code{\link[=sdg_clean]{sdg_clean()}}.
}
