Is there a way to obtain the list of countries, regions (?) and continents the rworldmap package supports when I want to join data?
I did some google searches and am just starting off with R.
Thanks.
It seems to me the rworldmap
package provides some additional functionality on top of the maps
package.
If this is indeed the case, you can do the following:
library(maps)
x <- map("world", plot=FALSE)
str(x)
List of 4
$ x : num [1:27121] -130 -130 -132 -132 -132 ...
$ y : num [1:27121] 55.9 56.1 56.7 57 57.2 ...
$ range: num [1:4] -180 190.3 -85.4 83.6
$ names: chr [1:2284] "Canada" "South Africa" "Denmark" "Great Lakes:Superior, Huron, Michigan" ...
- attr(*, "class")= chr "map"
This extracts the maps
database, and the element names
contains the name for each map polygon. These names are in fact a multi-level list where the elements are separated by colons. For example, to get the list of polygons belonging to the UK:
x$names[grep("UK", x$names)]
[1] "UK:Gibralter"
[2] "UK:Scotland:Isle of Lewis"
[3] "UK:Pitcairn Island"
[4] "UK:Guernsey"
[5] "UK:Great Britain"
[6] "UK:Scotland:Shetland Islands:Unst"
[7] "UK:Saint Mary's"
[8] "UK:Scotland:Shetland Islands:Yell"
[9] "UK:Northern Ireland"
[10] "UK:Bermuda"
[11] "UK:Tristan da Cunha Island"
[12] "UK:Scotland:Saint Kilda"
[13] "UK:Scotland:Ruhm"
[14] "UK:Scotland:Benbecula"
[15] "UK:Scotland:North Uist"
[16] "UK:Saint Helena Island"
[17] "UK:Scotland:Island of Skye"
[18] "UK:Scotland:Barra"
[19] "UK:Scotland:Island of Mull"
[20] "UK:Henderson Island"
[21] "UK:Isle of Sheppey"
[22] "UK:Jersey"
[23] "UK:Scotland:Coll"
[24] "UK:Scotland:Jura"
[25] "UK:Scotland:Island of Arran"
[26] "UK:Scotland:Tiree"
[27] "UK:Scotland:Islay"
[28] "UK:Ascension Island"
[29] "UK:Scotland:Colonsay"
[30] "UK:Scotland:Shetland Islands:Mainland"
[31] "UK:Scotland:South Uist"
[32] "UK:Scotland:Orkney Islands:Hoy"
[33] "UK:Gough Island"
[34] "UK:Scotland:Orkney Islands:Mainland"