Produce maps of regional level data from country level data

Share:

Description

This function will produce maps of regional statistics by aggregating country level data. For example mapping the total population of Asia, Europe,etc, from country level population data. As well as sums, other functions can be used, like mean, median, min, max, etc. There are currently 8 choices of region and 4 choices of country code.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
mapByRegion(inFile
           , nameDataColumn
					 , joinCode
					 , nameJoinColumn
					 , regionType
					 , FUN = 'mean'
					 , na.rm=TRUE
					 , mapTitle = ''
					 , lwd = 0.5
					 , ...)

Arguments

inFile

a data frame

nameDataColumn

The name of a column of inFile. This is data is aggregated by FUN

joinCode

The type of code to join with. Must be one of: "ISO2", "ISO3", "Numeric" or "FIPS"

nameJoinColumn

The name of a column of inFile. Contains joining codes.

regionType

Must be one of: "GEO3", "GEO3major", "IMAGE24", "GLOCAF", "Stern", "SRES", "SRESmajor","GBD","AVOIDname"

FUN

A function to apply to each region

na.rm

Only used for certain values of FUN. See details section below.

mapTitle

a title to be printed above the map

lwd

line width for country borders

...

further arguments to be passed to mapCountryData

Details

The function is very similar to country2Region. The first difference is that the output is a map, rather than statistics. The second is the behaviour of extra arguments. In country2Region the extra arguments go to FUN, here they go to mapCountryData.

The na.rm argument is used when FUN has one of the following values: "mean", "min", "max", "median", "range", "var", "sd", "mad" or "IQR". This reduces the problem of not being able to supply extra arguments to FUN.

Value

invisibly returns a list containing the data and main options used for the map, the list can be passed to addMapLegend along with additional options to allow greater flexibility in legend creation.

See Also

An alternative tool to country2Region. The plotting is done by mapCountryData

Examples

1
2
3
4
5
6
7
8
9
data(countryExData)

mapByRegion(inFile=countryExData
		        ,nameDataColumn="CLIMATE"
		        ,joinCode="ISO3"
		        ,nameJoinColumn="ISO3V10"
		        ,regionType="Stern"
	         	,FUN='mean'
	         	)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.