Produce maps of regional level data from country level data
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.
mapByRegion(inFile, nameDataColumn, joinCode, nameJoinColumn, regionType = "", FUN = "mean", na.rm = TRUE, mapTitle = "", lwd = 0.5, ...)
- a data frame
- The name of a column of inFile. This is data is aggregated by FUN
- The type of code to join with. Must be one of: "ISO2", "ISO3", "Numeric" or "FIPS"
- The name of a column of inFile. Contains joining codes.
- Must be one of: "GEO3", "GEO3major", "IMAGE24", "GLOCAF", "Stern", "SRES", "SRESmajor","GBD","AVOIDname"
- A function to apply to each region
- Only used for certain values of FUN. See details section below.
- a title to be printed above the map
- line width for country borders
- further arguments to be passed to
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.
invisibly returns a list containing the data and main options used
for the map, the list can be passed to
addMapLegendalong with additional options to allow greater flexibility in legend creation.
data(countryExData) mapByRegion(inFile=countryExData ,nameDataColumn="CLIMATE" ,joinCode="ISO3" ,nameJoinColumn="ISO3V10" ,regionType="Stern" ,FUN='mean' )