Identify countries by ISO 3166 codes (2 or 3 letters) or by Sovereignty.
This data set and the simple look-up functions allow to build lists of counrtries for the world map.
iso.expand(a, regex=TRUE) sov.expand(sov, regex=TRUE) iso.alpha(x, n=2)
a |
A vector of ISO codes. All elements should have the same length, either 2 or 3 letters. Not case sensitive. |
sov |
A vector of country names. The result is a list of all countries that fall under their sovereignty. Case sensitive, must fit completeley. |
regex |
If TRUE (default), the return vector has the same length as the input ( |
x |
Vector of country names, may include colons. |
n |
An integer identitying which ISO code is required. Allowed values are 2 and 3. |
The ISO 3166-1 standard identifies countries by a 2 and 3 letter codes.
iso.expand
translates these codes into the country names as used by
the world
data base. iso.alpha
does the reverse.
Note that these functions will not work well with the legacy world data base.
Some countries have different ISO codes for different regions
(e.g. China:Hong Kong has ISO code HK). In such cases, iso.alpha
will
return the main code, but iso.expand
will return a regular expression
that excludes some parts.
iso.expand
returns vector of country names. When used as input for map
it will plot all the countries as identified either by their sovereignty or by ISO codes. If regex=FALSE
the length of the vector may be shorter or longer than the input. If regex=TRUE
, the results are concatenated in regular expressions. This format is less readable, but can be used as input e.g. for match.map
.
iso.alpha
always returns a vector of the same length as the input, containing the 2- or 3-letter codes.
These functions use regular expressions and the results will often not work well with map(...,exact=TRUE)
.
# France and all its overseas departments, territories etc. sov.expand("France") # France and all its overseas departments, territories etc. # Canary Islands are not included in map("Spain") iso.expand("ES") map(regions=sov.expand("Spain")) # draw a map with ISO codes as labels: wm <- map("world", fill=TRUE, col=0, xlim=c(-10,40), ylim=c(30,60)) # take out islands, but you loose e.g. UK, New Zealand, small island states nam <- grep(":", wm$names, inv=TRUE, val=TRUE) # ad ISO codes as label map.text(wm, regions=nam, label=iso.alpha(nam), col=2, exact=TRUE, add=TRUE)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.