joinCountryData2Map {rworldmap}R Documentation

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
)

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

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")

Value

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

Author(s)

andy south

See Also

mapCountryData, getMap

Examples


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

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



[Package rworldmap version 1.3-8 Index]