View source: R/labelCountries.r
labelCountries | R Documentation |
Given no arguments it will print country names stored in the 'NAME' column
of getMap
onto an existing map at the centroids of each
country polygon, stored in the 'LAT' and 'LON' columns. Alternatively the
user can specifiy a data frame or SpatialPolygonsDataFrame in which case
they need to define the column containing the country names
(nameCountryColumn) and optionally a 2nd attribute column to print
(nameColumnToPlot). First you need to create a map plot, for example using
mapCountryData
or mapBubbles
.
labelCountries(
dF = "",
nameCountryColumn = "NAME",
nameX = "LON",
nameY = "LAT",
nameColumnToPlot = "",
col = "grey",
cex = 0.8,
...
)
dF |
dataframe or SpatialPolygonsDataFrame |
nameCountryColumn |
name of column containing country names to be printed on the map (could also be set to any other column in the dataframe) |
nameX |
name of column containing the X variable (longitude), not needed if dF is a SpatialPolygonsDataFrame |
nameY |
name of column containing the Y variable (lattitude), not needed if dF is a SpatialPolygonsDataFrame |
nameColumnToPlot |
name of an attribute column in the data frame the value of which will be appended to the country names |
col |
colour for labels, default 'grey', can be e.g. rgb(1,1,0,alpha=0.5) |
cex |
sizing of labels, default = 0.8 |
... |
other parameters that can be passed to text(), e.g. pos=4 to right, (1=below, 2=left, 3=above) |
nothing
andy south
identifyCountries
mapCountryData()
labelCountries()
labelCountries(nameColumnToPlot = "POP_EST")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.