Learn R Programming

rworldmap (version 1.3-8)

joinCountryData2Map: Joins user country referenced data to a map

Description

Joins user data referenced by country codes or names to an internal map, ready for plotting using mapCountryData. Reports join successes and failures.

Usage

joinCountryData2Map(
  dF,
  joinCode = "ISO3",
  nameJoinColumn = "ISO3V10",
  nameCountryColumn = "Country",
  suggestForFailedCodes = FALSE,
  mapResolution = "coarse",
  projection = NA,
  verbose = FALSE
)

Value

An R 'SpatialPolygonsDataFrame' [package "sp"] object with the passed data joined to it

Arguments

dF

R data frame with at least one column for country reference and one column of data

joinCode

how countries are referenced options "ISO2","ISO3","FIPS","NAME", "UN" = numeric codes

nameJoinColumn

name of column containing country referencing

nameCountryColumn

optional name of column containing country names (used in reporting of success/failure)

suggestForFailedCodes

NOT YET ENABLED T/F whether you want system to suggest for failed codes

mapResolution

resolution of the borders in the internal map, only for projection='none' : options 'low', 'medium'

projection

DEPRECATED JUNE 2012

verbose

if set to FALSE it doesn't print progress messages to console

Author

andy south

Details

Joins data referenced by country codes to an internally stored map to enable plotting. The user specifies which country code their data are referenced by, and the name of the column in their data containing that referencing data. The user can choose from different map resolutions, using the function getMap to retrieve the map. The function reports on how many countries successfully join to the map. Data can then be plotted using mapCountryData. NEW to version 1.01 Oct 2012 : for joinCode='NAME' alternative country names are matched using countrySynonyms.

The projection argument has now been deprecated, you can project maps using package rgdal as shown below and in the FAQ.
library(rgdal)
#first get countries excluding Antarctica which crashes spTransform
sPDF <- getMap()[-which(getMap()$ADMIN=='Antarctica'),]
#transform to robin for the Robinson projection
sPDF <- spTransform(sPDF, CRS=CRS("+proj=robin +ellps=WGS84"))
mapCountryData( sPDF, nameColumnToPlot="REGION")

See Also

mapCountryData, getMap

Examples

Run this code

data("countryExData",envir=environment(),package="rworldmap")

sPDF <- joinCountryData2Map(countryExData
              , joinCode = "ISO3"
              , nameJoinColumn = "ISO3V10"
              )
mapCountryData( sPDF
              , nameColumnToPlot="BIODIVERSITY" 
              )


Run the code above in your browser using DataLab