1\name{iso.expand} 2\alias{sov.expand} 3\alias{iso.expand} 4\alias{iso.alpha} 5\title{ 6 Identify countries by ISO 3166 codes (2 or 3 letters) or by Sovereignty. 7} 8\description{ 9 This data set and the simple look-up functions allow to build lists of counrtries for the world map. 10 } 11\usage{ 12 iso.expand(a, regex=TRUE) 13 sov.expand(sov, regex=TRUE) 14 iso.alpha(x, n=2) 15} 16\arguments{ 17 \item{a}{A vector of ISO codes. All elements should have the same length, either 2 or 3 letters. Not case sensitive.} 18 \item{sov}{A vector of country names. The result is a list of all countries that fall under their sovereignty. Case sensitive, must fit completeley.} 19 \item{regex}{If TRUE (default), the return vector has the same length as the input (\code{a} or \code{sov}), but the entries may be regular expressions. 20If FALSE, the result is a vector of polygon names. This may be more readable, but the return vector may be longer than the input.} 21 \item{x}{Vector of country names, may include colons.} 22 \item{n}{An integer identitying which ISO code is required. Allowed values are 2 and 3.} 23} 24\details{ 25 The ISO 3166-1 standard identifies countries by a 2 and 3 letter codes. 26\code{iso.expand} translates these codes into the country names as used by 27the \code{world} data base. \code{iso.alpha} does the reverse. 28Some countries have different ISO codes for different regions 29(e.g. China:Hong Kong has ISO code HK). In such cases, \code{iso.alpha} will 30return the main code, but \code{iso.expand} will return a regular expression 31that excludes some parts. 32} 33\value{ 34 \code{iso.expand} returns vector of country names. When used as input for \code{map} it will plot all the countries as identified either by their sovereignty or by ISO codes. If \code{regex=FALSE} the length of the vector may be shorter or longer than the input. If \code{regex=TRUE}, the results are concatenated in regular expressions. This format is less readable, but can be used as input e.g. for \code{match.map}. 35\code{iso.alpha} always returns a vector of the same length as the input, containing the 2- or 3-letter codes. 36} 37\section{NOTE}{ 38These functions use regular expressions and the results will often not work well with \code{map(...,exact=TRUE)}. 39} 40\seealso{ 41\code{\link{match.map}},\code{\link{map.text}},\code{\link{iso3166}} 42} 43\references{ 44\url{https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2} 45} 46\examples{ 47# France and all its overseas departments, territories etc. 48sov.expand("France") # France and all its overseas departments, territories etc. 49 50# Canary Islands are not included in map("Spain") 51iso.expand("ES") 52map(regions=sov.expand("Spain")) 53 54# draw a map with ISO codes as labels: 55wm <- map("world", fill=TRUE, col=0, xlim=c(-10,40), ylim=c(30,60)) 56# take out islands, but you loose e.g. UK, New Zealand, small island states 57nam <- grep(":", wm$names, inv=TRUE, val=TRUE) 58# ad ISO codes as label 59map.text(wm, regions=nam, label=iso.alpha(nam), col=2, exact=TRUE, add=TRUE) 60} 61