Learn R Programming

bayesLife (version 5.2-0)

e0.map: World Map of the Life Expectancy

Description

Generates a world map of the life expectancy for given quantile and projection or estimation period, using different techniques: e0.map and e0.map.all use rworldmap, e0.ggmap uses ggplot2, and e0.map.gvis creates an interactive map via GoogleVis.

Usage

e0.map(pred, ...)
	
e0.ggmap(pred, ...)

e0.map.all(pred, output.dir, output.type = "png", e0.range = NULL, nr.cats = 50, same.scale = TRUE, quantile = 0.5, file.prefix = "e0wrldmap_", ...) get.e0.map.parameters(pred, e0.range = NULL, nr.cats = 50, same.scale = TRUE, quantile = 0.5, ...) e0.map.gvis(pred, ...)

Value

get.e0.map.parameters returns a list with elements:

pred

The object of class bayesLife.prediction used in the function.

quantile

Value of the argument quantile.

catMethod

If the argument same.scale is TRUE, this element contains breakpoints for categorization. It is generated from a fitted gamma distribution. Otherwise, it is NULL.

numCats

Number of categories.

coulourPalette

Subset of the rainbow palette, starting from dark blue and ending at red.

...

Additional arguments passed to the function.

Arguments

pred

Object of class bayesLife.prediction.

output.dir

Directory into which resulting maps are stored.

output.type

Type of the resulting files. It can be “png”, “pdf”, “jpeg”, “bmp”, “tiff”, or “postscript”.

e0.range

Range of the life expectancy to be displayed. It is of the form c(e0.min, e0.max). By default, the whole range is considered. Note that countries with values outside of the given range will appear white.

nr.cats

Number of color categories.

same.scale

Logical controlling if maps for all years of this prediction object should be on the same color scale.

quantile

Quantile for which the map should be generated. It must be equal to one of the values in dimnames(pred$quantiles[[2]]), i.e. 0, 0.025, 0.05, 0.1, 0.2, 0.25, 0.3, 0.4, 0.5, 0.6, 0.7, 0.75, 0.8, 0.9, 0.95, 0.975, 1. Value 0.5 corresponds to the median.

file.prefix

Prefix for file names.

...

In e0.map, ... are all arguments that can be passed to tfr.map, such as quantile, year, projection.index, par.name, adjusted, device, main, device.args, and data.args. In e0.map.gvis, ... are all arguments that can be passed to tfr.map.gvis. In e0.ggmap, ... are arguments that can be passed to tfr.ggmap. In addition, functions that use the rworldmap package accept arguments passed to the rworldmap::mapCountryData function.

Author

Hana Sevcikova, Adrian Raftery

Details

e0.map creates a single map for the given time period and quantile. e0.map.all generates a sequence of maps, namely one for each projection period. If the package fields is installed, a color bar legend at the botom of the map is created.

Function get.e0.map.parameters can be used in combination with e0.map. (Note that get.e0.map.parameters is called from inside of e0.map.all.) It sets breakpoints for the color scheme using quantiles of a fitted gamma distribution.

Function e0.ggmap is similar to e0.map, but used the ggplot2 package in combination with the geom_sf function.

Function e0.map.gvis creates an interactive map using the googleVis package and opens it in an internet browser. It also generates a table of the mapped values that can be sorted by columns interactively in the browser.

By default, both e0.map, e0.ggmap and e0.map.gvis produce maps of life expectancy. Alternatively, the functions can be used to plot country-specific MCMC parameters into a world map. They are given by the argument par.name. One can pass any value from e0.parameter.names.cs.extended().

See Also

tfr.map

Examples

Run this code
if (FALSE) {
sim.dir <- file.path(find.package("bayesLife"), "ex-data", "bayesLife.output")
pred <- get.e0.prediction(sim.dir = sim.dir)

# Using ggplot2
e0.ggmap(pred, same.scale = TRUE)
e0.ggmap(pred, year = 2100, same.scale = TRUE)

# Using rworldmap
# Uses heat colors and seven categories by default
e0.map(pred)
# Uses more colors with more suitable categorization
params <- get.e0.map.parameters(pred)
do.call('e0.map', params)
# Another projection year on the same scale
do.call('e0.map', c(list(year = 2043), params))

# Interactive map (requires Flash)
e0.map.gvis(pred, year = 2043)}

Run the code above in your browser using DataLab